-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[exporter/elasticsearch] Data stream routing based on data_stream.*
attributes
#33794
[exporter/elasticsearch] Data stream routing based on data_stream.*
attributes
#33794
Conversation
5d01e7e
to
cf382bc
Compare
encodeSpan(pcommon.Resource, ptrace.Span, pcommon.InstrumentationScope) ([]byte, error) | ||
upsertMetricDataPoint(map[uint32]objmodel.Document, pcommon.Resource, pcommon.InstrumentationScope, pmetric.Metric, pmetric.NumberDataPoint) error |
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, this is ugly. But the "grouping" idea doesn't fit into the separation between exporter and encoding model. Happy to take any suggestions. If it isn't blocking, we can defer it to a future refactoring PR.
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.
Probably the cleanest separation would be for the encoding model to decide whether it creates one or more documents. Doing this in a followup sounds reasonable.
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.
Looks good overall. I'd really like to avoid more configuration if we can.
encodeSpan(pcommon.Resource, ptrace.Span, pcommon.InstrumentationScope) ([]byte, error) | ||
upsertMetricDataPoint(map[uint32]objmodel.Document, pcommon.Resource, pcommon.InstrumentationScope, pmetric.Metric, pmetric.NumberDataPoint) error |
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.
Probably the cleanest separation would be for the encoding model to decide whether it creates one or more documents. Doing this in a followup sounds reasonable.
return comp | ||
} | ||
|
||
func assertItemsEqual(t *testing.T, expected, actual []itemRequest, assertOrder bool) { |
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.
Probably a followup, but seems like we could get by with assert.ElementsMatch
if we were to convert the raw JSON to strings, and compare those. I expect the error messages would be more useful then too.
// Fetch value according to precedence and default. | ||
value := getFromAttributesNew(attributeName, defaultValue, recordAttributes, scopeAttributes, resourceAttributes) | ||
|
||
// Always set the value on the record, as record attributes have the highest precedence. |
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.
// Always set the value on the record, as record attributes have the highest precedence. | |
// Set the attribute in case the default value is used. | |
// | |
// Always set the value on the record, as record attributes have the highest precedence. |
I think? Should we only do this if value == defaultValue
?
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.
Scope attributes are not read in the encodeModel, meaning that only Resource and DataPoint attributes are added to the Document. This is aligned with the behavior of apm-data, where scope attributes are only read for data_stream.* and anything else is ignored, see code. Let me know if you find this behavior problematic.
Should we only do this if value == defaultValue
Therefore, the problem of doing this is that if data_stream.* is present in scope attributes, they will be missing from the resulting doc.
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 see, thanks. Seems odd, but not something we need to change right now.
Co-authored-by: Andrew Wilkins <axwalk@gmail.com>
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.
LGTM - we should reenable TestEncodeMetric
data_stream.*
attributes
Description:
Taking over from #33755
data_stream.*
attributesLink to tracking Issue:
Closes #33755
Fixes #33756
Testing:
See unit tests
Documentation:
Updated readme