-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default environment #3
Conversation
|
||
/** | ||
* The LogGroup name to use. This will be ignored when using the | ||
* Lambda scope. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you probably copied this from the other repos, but we can be explicit in the javadocs and say that this is really just for the CWAgent.
@@ -0,0 +1,7 @@ | |||
package software.amazon.awssdk.services.cloudwatchlogs.emf.config; | |||
|
|||
class SystemWrapper { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Configuration is a singleton and is created by EnvironmentConfigurationProvider. The Provider reads environment variables from System. It's difficult to mock the System to test the EnvironmentConfigurationProvider, so I used SystemWrapper to make it possible to mock System.
@@ -65,4 +67,9 @@ void putMetric(String key, double value) { | |||
} | |||
return dimensions; | |||
} | |||
|
|||
String serialize() throws JsonProcessingException { | |||
ObjectMapper mapper = new ObjectMapper(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to create an ObjectMapper every time? Also, recommend looking at this issue: awslabs/aws-embedded-metrics-node#50
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Added a property filter to filter out the _aws
if no metrics have been defined.
/** | ||
* Establish a connection to a socket | ||
*/ | ||
void connect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want this on the interface? The socket client needs to manage some state anyways and connect can probably be encapsulated rather than require the sink to call it before sendMessage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed this issue
|
||
@Override | ||
public void sendMessage(String message) { | ||
if (socket.isClosed() || shouldConnect) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a thread safe operation. Is this class used across threads?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's possible that this class is used across threads.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the Python lib, we address this using 2 instance-level locks for writes and connecting. https://github.com/awslabs/aws-embedded-metrics-python/blob/master/aws_embedded_metrics/sinks/tcp_client.py#L35
- Filter out '_aws' metadata object if no metrics have been added - Add lock for sendMessage method
Issue #, if available:
Description of changes:
TODO:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.