Skip to content

fix(proto): preserve InstrumentationScope version and attributes#3332

Merged
cijothomas merged 13 commits into
open-telemetry:mainfrom
djvcom:fix/preserve-instrumentation-scope-metadata
Apr 28, 2026
Merged

fix(proto): preserve InstrumentationScope version and attributes#3332
cijothomas merged 13 commits into
open-telemetry:mainfrom
djvcom:fix/preserve-instrumentation-scope-metadata

Conversation

@djvcom

@djvcom djvcom commented Jan 30, 2026

Copy link
Copy Markdown
Contributor

Summary

When logs have a target set, the InstrumentationScope's version and attributes were being discarded during OTLP export. The target parameter now correctly overrides only the scope name, preserving other metadata.

  • Fix From implementations for InstrumentationScope to preserve version and attributes when target is provided
  • Add unit tests for the From implementations
  • Add integration test demonstrating the fix with group_logs_by_resource_and_scope

Context

This behaviour was introduced in PR #1869 to avoid exporting the appender crate's version when the scope name was overridden by target. However, PRs #2735 and #2796 subsequently changed both appenders to use empty scopes, so this concern no longer applies. Additionally, users who explicitly create scopes via logger_with_scope() would reasonably expect their metadata to be preserved.

Test plan

  • Unit tests for both owned and reference From implementations
  • Integration test for group_logs_by_resource_and_scope with target set
  • cargo test -p opentelemetry-proto --all-features --lib passes
  • cargo clippy -p opentelemetry-proto --all-features -- -Dwarnings passes

Fixes #3276

When logs have a target set, the InstrumentationScope's version and
attributes were being discarded during OTLP export. The target parameter
now correctly overrides only the scope name, preserving other metadata.

This behaviour was introduced in PR open-telemetry#1869 to avoid exporting the
appender crate's version when the scope name was overridden by target.
However, PRs open-telemetry#2735 and open-telemetry#2796 subsequently changed both appenders to use
empty scopes, so this concern no longer applies. Additionally, users who
explicitly create scopes via logger_with_scope() would reasonably expect
their metadata to be preserved.

Fixes open-telemetry#3276
@djvcom
djvcom requested a review from a team as a code owner January 30, 2026 14:08
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jan 30, 2026

Copy link
Copy Markdown

CLA Signed

The committers listed above are authorized under a signed CLA.

@codecov

codecov Bot commented Jan 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.5%. Comparing base (329dc2d) to head (9a16a2d).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##            main   #3332     +/-   ##
=======================================
+ Coverage   83.4%   83.5%   +0.1%     
=======================================
  Files        127     127             
  Lines      25197   25241     +44     
=======================================
+ Hits       21026   21091     +65     
+ Misses      4171    4150     -21     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@djvcom

djvcom commented Jan 30, 2026

Copy link
Copy Markdown
Contributor Author

Hi there, first time contributing here so please let me know if I need to change anything (or if I'm not allowed to contribute etc). Sorry if I've done anything wrong!

Comment thread opentelemetry-proto/src/transform/common.rs
@scottgerring

Copy link
Copy Markdown
Member

I note this fixes the same bug that @calavera calavera started looking at in #3175

@djvcom

djvcom commented Feb 17, 2026

Copy link
Copy Markdown
Contributor Author

@scottgerring yep, I did look at his work as a reference point for getting started on it. Do you think this is still needed? Happy to make any changes as required or close if not? I'd forgotten about it 😅

@scottgerring

Copy link
Copy Markdown
Member

@scottgerring yep, I did look at his work as a reference point for getting started on it. Do you think this is still needed? Happy to make any changes as required or close if not? I'd forgotten about it 😅

As there's a couple folks who've hit it now and this looks like a clean change to me I reckon we should merge it. @cijothomas wdyt?

@cijothomas
cijothomas added this pull request to the merge queue Mar 13, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Mar 13, 2026
@scottgerring

Copy link
Copy Markdown
Member

@cijothomas this one looks like it's been hit with the merge queue issues too ?

@bryantbiggs

Copy link
Copy Markdown
Contributor

@scottgerring / @cijothomas feel free to tag me when you come across any flaky tests - hopefully we can burn those down so that CI is a bit more reliable and approved PRs are less likely to get kicked out of the merge queue. I see it was updated with main so hopefully that fixed the flaky tests it encountered

@djvcom

djvcom commented Apr 8, 2026

Copy link
Copy Markdown
Contributor Author

Hi @cijothomas, I'm wondering whether there's anything I can do on this one to get it merged? Or would you prefer I close the PR? (Just trying to wrap up some loose ends).

@djvcom

djvcom commented Apr 21, 2026

Copy link
Copy Markdown
Contributor Author

Hi @scottgerring, I'm not sure whether you might be able to help get this one merged (or let me know if I should close it)? Sorry to chase!

@scottgerring

Copy link
Copy Markdown
Member

Hi @scottgerring, I'm not sure whether you might be able to help get this one merged (or let me know if I should close it)? Sorry to chase!

Hey @djvcom , @cijothomas and @lalitb should be back on deck this week and hold the merge keys; pinging for visibility

@cijothomas
cijothomas enabled auto-merge April 27, 2026 18:30
@cijothomas

Copy link
Copy Markdown
Member

Hi @scottgerring, I'm not sure whether you might be able to help get this one merged (or let me know if I should close it)? Sorry to chase!

Hey @djvcom , @cijothomas and @lalitb should be back on deck this week and hold the merge keys; pinging for visibility

Added to merge-queue. There are some Github issues going on right now, so this will be merged as soon as they are resolved.

@cijothomas
cijothomas added this pull request to the merge queue Apr 28, 2026
Merged via the queue into open-telemetry:main with commit de0d58c Apr 28, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: opentelemetry-proto discards InstrumentationScope attributes for logs

5 participants