Calling `setDimensions` in ECSEnvironment causes default properties to be added in the first emitted log.
Closed this issue · 2 comments
Hello,
I think that this issue is similar to a closed issue, but I am posting here, since that one is closed.
Currently, MetricsLogger checks whether the context has any default dimensions, which checks the size of the default dimensions. This means that if we call setDimensions
to prevent any default properties from showing up, following happens...
- For the first metric, ECSEnvironment will supply the default dimensions and the properties to the metric, because there is no default dimensions.
- So the first metric log will contain ECS information like
image
and such.
- So the first metric log will contain ECS information like
- For the second and subsequent metrics, ECSEnvironment won't supply any properties to the metric, because the default dimension was set from the first metric.
- So the subsequent metric log will not contain any ECS information...
Is this an expected behavior? Is there a way to prevent the ECS environment info from showing up at all?
Thank you.
Example:
First log entry:
{
"_aws": ...,
"createdAt": "...",
"image": "...",
"cluster": "...",
"taskArn": "...",
"startedAt": "...",
"containerId": "."..
...
}
Second log entry:
{
"_aws": ...,
...
}
@5lbBookOfGre Hi, I don't think there's a causal relationship between setDimensions
and the default properties. If taking a closer look at the code, setDimensions
disables the default dimensions by setting the shouldUseDefaultDimension
flag as false in MetricDirective rather than clearing up the existing ones:
So once the default dimensions are initialized after first flush, the
hasDefaultDimensions()
would return true and default properties would not be added anymore.
Please inform me if I'm getting anything wrong here. Also it would be helpful if you can provide more context or code snippet for your use case~