Skip to content
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

Noop If Empty Metrics? #50

Open
metaskills opened this issue Jul 12, 2020 · 4 comments
Open

Noop If Empty Metrics? #50

metaskills opened this issue Jul 12, 2020 · 4 comments
Labels
enhancement New feature or request good first issue Good for newcomers question Further information is requested

Comments

@metaskills
Copy link

I'm using the following code to have only one dimension.

metrics.setDimensions();

In some cases for my Lambda there will not be any metrics. However, I have noticed in my log that an empty metric is published. For example:

{"executionEnvironment":"AWS_Lambda_nodejs12.x","memorySize":"1792","functionVersion":"$LATEST","logStreamId":"2020/07/12/[$LATEST]9a0092bb2cf76b6b90c46bf429a32aef","traceId":"Root=1-dc99d00f-c079a84d433534434534ef0d;Parent=91ed514f1e5c03b2;Sampled=1","_aws":{"Timestamp":1594571647673,"CloudWatchMetrics":[{"Dimensions":[],"Metrics":[],"Namespace":"MyApp"}]}}

Should this library check for dimension/metric presence before sending the output?

@jaredcnance
Copy link
Member

jaredcnance commented Jul 12, 2020

I’m not entirely sure what you’re asking. Are you saying that if no metrics or dimensions have been specified we should not embed the _aws object in the JSON? Or you want to prevent the log from being emitted entirely if there are no metrics?

@jaredcnance jaredcnance added the question Further information is requested label Jul 12, 2020
@metaskills
Copy link
Author

Yes, that's what I'm asking.

@jaredcnance
Copy link
Member

jaredcnance commented Jul 12, 2020

Which one? I think we could make dropping the log entirely configurable. Some use setProperty and still want the logs emitted. I think it's reasonable to drop the _aws object if no metrics have been added, but I don't think we can assume that the log shouldn't be emitted by default. This is not the current default behavior, but is relatively straightforward to implement. This would require modifications in the LogSerializer.

@jaredcnance jaredcnance added enhancement New feature or request good first issue Good for newcomers and removed good first issue Good for newcomers labels Jul 12, 2020
@metaskills
Copy link
Author

Agreed, I think just the _aws logic is what I was asking for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants