opentelemetry-rust icon indicating copy to clipboard operation
opentelemetry-rust copied to clipboard

Make overriding `scope.name` with `logrecord.target` configurable in OTLP Log Exporter

Open lalitb opened this issue 1 year ago • 1 comments

Fixes #1890 Design discussion issue (if applicable) #

Changes

  • Added feature flag populate-instrumentation-scope-from-target in Cargo.toml for opentelemetry-otlp and opentelemetry-proto.
  • The flag is enabled by default for both.
  • If flag is enabled scope.name is populated with LogRecord.target. scope.version and other fields are empty.
  • If flag is disabled, scope is populated from opentelemetry-sdk's "InstrumentatonLibrary".

output for:

    info!(name: "my-event", target: "my-target", "hello from {}. My price is {}", "apple", 1.99);

feature flag disabled


2024-09-11T09:33:21.399Z        info    LogsExporter    {"kind": "exporter", "data_type": "logs", "name": "debug", "resource logs": 1, "log records": 1}
2024-09-11T09:33:21.399Z        info    ResourceLog #0
Resource SchemaURL:
Resource attributes:
     -> service.name: Str(basic-otlp-example)
ScopeLogs #0
ScopeLogs SchemaURL:
InstrumentationScope opentelemetry-appender-tracing 0.25.0
LogRecord #0
ObservedTimestamp: 2024-09-11 09:33:21.3943082 +0000 UTC
Timestamp: 1970-01-01 00:00:00 +0000 UTC
SeverityText: INFO
SeverityNumber: Info(9)
Body: Str(hello from apple. My price is 1.99)
Trace ID:
Span ID:
Flags: 0
        {"kind": "exporter", "data_type": "logs", "name": "debug"}

feature flag enabled


2024-09-11T09:33:51.736Z        info    LogsExporter    {"kind": "exporter", "data_type": "logs", "name": "debug", "resource logs": 1, "log records": 1}
2024-09-11T09:33:51.737Z        info    ResourceLog #0
Resource SchemaURL:
Resource attributes:
     -> service.name: Str(basic-otlp-example)
ScopeLogs #0
ScopeLogs SchemaURL:
InstrumentationScope my-target
LogRecord #0
ObservedTimestamp: 2024-09-11 09:33:51.7344587 +0000 UTC
Timestamp: 1970-01-01 00:00:00 +0000 UTC
SeverityText: INFO
SeverityNumber: Info(9)
Body: Str(hello from apple. My price is 1.99)
Trace ID:
Span ID:
Flags: 0
        {"kind": "exporter", "data_type": "logs", "name": "debug"}

Merge requirement checklist

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

lalitb avatar Sep 11 '24 08:09 lalitb

Codecov Report

Attention: Patch coverage is 58.33333% with 5 lines in your changes missing coverage. Please review.

Project coverage is 77.9%. Comparing base (e206533) to head (48463eb). Report is 371 commits behind head on main.

Files with missing lines Patch % Lines
opentelemetry-proto/src/transform/logs.rs 58.3% 5 Missing :warning:
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #2102     +/-   ##
=======================================
- Coverage   78.0%   77.9%   -0.1%     
=======================================
  Files        121     121             
  Lines      20939   20944      +5     
=======================================
+ Hits       16335   16336      +1     
- Misses      4604    4608      +4     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Sep 11 '24 08:09 codecov[bot]

Closing as this is not desired. Will continue to use target to populate scope as required by the spec. Once the convention for storing attributes for appender name/version is settled, we can adapt it.

cijothomas avatar Feb 23 '25 16:02 cijothomas