-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[elasticsearchexporter]: Add dynamic document id support for logs #37065
[elasticsearchexporter]: Add dynamic document id support for logs #37065
Conversation
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 at a high level, thanks!
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.
Q: do you expect the elasticsearch.document_id
to be indexed under attributes as well, or should it be ignored during serialization?
Haven't thought of that, but I think it makes sense to remove the field, as it only has meaning for the exporter. Also, |
I updated the code to remove the id field from the final document. Regarding the attribute name, I wonder if we should stick to some kind of semantic convention such as https://opentelemetry.io/docs/specs/semconv/database/elasticsearch/. I scrolled throught it but couldn't find an existing attribute for a document id. |
Co-authored-by: Carson Ip <carsonip@users.noreply.github.com>
Co-authored-by: Carson Ip <carsonip@users.noreply.github.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, just a couple of nits
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #37065 +/- ##
=======================================
Coverage 79.57% 79.57%
=======================================
Files 2271 2271
Lines 212855 212872 +17
=======================================
+ Hits 169372 169392 +20
- Misses 37794 37797 +3
+ Partials 5689 5683 -6 ☔ View full report in Codecov by Sentry. |
needs a rebase |
Interesting, I fixed the conflicts but now the tests fail with I believe this is because a PR yesterday changed MutatesData to false #37234. What should be the course of action here? The idea of the attribute defined here is that we remove it from the final document. |
@felixbarny any suggestion here? |
Instead of removing the attribute from the original opentelemetry-collector-contrib/exporter/elasticsearchexporter/pdata_serializer.go Lines 297 to 308 in a151d16
IIUC, this is mostly relevant for the |
90a3f3c
to
0a34926
Compare
That is clever, worked like a charm. Thanks! |
CI failure seems to be unrelated with my changes. |
Description
This PR adds a new config option
logs_dynamic_id
that when set to true reads theelasticsearch.document_id
attribute from each log record and uses it as the final document id in Elasticsearch. This is only implemented for logs but I can open subsequent PRs supporting metrics and traces akin to the*_dynamic_index
options.Fixes #36882
Testing
Added tests to verify that the document ID attribute can be read from the log record and that the _id is properly forwarded to Elasticsearch. Also asserted that when there is no doc id attribute the current behavior is retained.
Documentation
Updated the readme to mention the new
logs_dynamic_id
config option.