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

Insert tracing event name into LogRecord::event_name instead of attributes #1928

Merged
merged 19 commits into from
Jul 13, 2024

Conversation

lalitb
Copy link
Member

@lalitb lalitb commented Jul 11, 2024

Changes

event_name field was added in LogRecord as part of #1488, however it was never populated with the name metadata in tracing appender. The name was instead added to the attributes. Ensuring this is now populated properly.

  • This may need changes in the custom exporters to serialize this field directly from LogRecord::event_name instead of iterating over the attributes.
  • The downstreams depending on the OTLP transformation will no longer receive this as attribute. We can separately decide if OTLP transformation code should add it as attribute (if not already existing).

Merge requirement checklist

  • CONTRIBUTING guidelines followed
  • Unit tests added/updated (if applicable)
  • Appropriate CHANGELOG.md files updated for non-trivial, user-facing changes
  • Changes in public API reviewed (if applicable)

@lalitb lalitb requested a review from a team July 11, 2024 18:36
Copy link

codecov bot commented Jul 11, 2024

Codecov Report

Attention: Patch coverage is 45.65217% with 25 lines in your changes missing coverage. Please review.

Project coverage is 74.9%. Comparing base (a2e435f) to head (0018b2f).

Files Patch % Lines
opentelemetry-stdout/src/logs/transform.rs 0.0% 19 Missing ⚠️
opentelemetry-proto/src/transform/logs.rs 62.5% 6 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #1928     +/-   ##
=======================================
- Coverage   74.9%   74.9%   -0.1%     
=======================================
  Files        122     122             
  Lines      20298   20308     +10     
=======================================
- Hits       15221   15217      -4     
- Misses      5077    5091     +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@cijothomas cijothomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a changelog entry, as this breaking behavior.
Are you planning to modify OTLPExporter to sent this as attribute (with same name as before), so this change will be transparent to the OTLPExporter users?

@lalitb
Copy link
Member Author

lalitb commented Jul 12, 2024

Please add a changelog entry, as this breaking behavior.
Are you planning to modify OTLPExporter to sent this as attribute (with same name as before), so this change will be transparent to the OTLPExporter users?

Added changelog.
Regarding OTLP Exporter, we need to iterate over attributes (we don't do right now) to add if not already existing. Should we really do that, or let the users invoke a custom processor to handle that before calling batch processor if they need this field?

@cijothomas
Copy link
Member

Added changelog.
Regarding OTLP Exporter, we need to iterate over attributes (we don't do right now) to add if not already existing

OTLP Should always add it to attributes. Why the condition "add if not already existing"?

@lalitb
Copy link
Member Author

lalitb commented Jul 12, 2024

OTLP Should always add it to attributes. Why the condition "add if not already existing"?

info!("message", name = "my_name")
info!(name: "event_name1", "message", name = "some_other_name")

In above scenario, there would be entry for LogRecord::event_name and also with "name" key in attributes. Should we let the OTLP attribute vector have both of these fields? Then we don't need to iterate, just add.

@lalitb
Copy link
Member Author

lalitb commented Jul 12, 2024

In above scenario, there would be entry for LogRecord::event_name and also with "name" key in attributes. Should we let the OTLP attribute vector have both of these fields? Then we don't need to iterate, just add.

Thinking again, we can keep the existing behavior - to have two entries with "name" key in the attributes vector in these specific scenarios - which means we can just add without iterating to check. This could be added in this PR itself.

@cijothomas
Copy link
Member

OTLP Should always add it to attributes. Why the condition "add if not already existing"?

info!("message", name = "my_name")
info!(name: "event_name1", "message", name = "some_other_name")

In above scenario, there would be entry for LogRecord::event_name and also with "name" key in attributes. Should we let the OTLP attribute vector have both of these fields? Then we don't need to iterate, just add.

yes please. (If the user does error!(name: "my-event-name", target: "my-system", event_id = 20, user_name = "otel", user_email = "otel@opentelemetry.io", name = "1", name = "2", name = 3); we'll have name repeated 4 times.)

@lalitb lalitb added the integration tests Run integration tests label Jul 12, 2024
@lalitb
Copy link
Member Author

lalitb commented Jul 12, 2024

yes please. (If the user does error!(name: "my-event-name", target: "my-system", event_id = 20, user_name = "otel", user_email = "otel@opentelemetry.io", name = "1", name = "2", name = 3); we'll have name repeated 4 times.)

Make sense. Done, along with updating the changelog. Also triggered integration test to validate.

lalitb and others added 3 commits July 12, 2024 14:00
@cijothomas cijothomas merged commit 6207882 into open-telemetry:main Jul 13, 2024
24 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration tests Run integration tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants