Skip to content

feat: add methods to get Resource set on in memory exporters #3070

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

davidhewitt
Copy link

Changes

As per title.

I was testing my pipeline setup and found that there was no way to validate the resource was getting all the way to the exporter correctly (I had a bug in a LogProcessor which was not forwarding it correctly).

If I had these methods, I'd be able to assert my pipeline was implemented correctly end-to-end.

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)

@davidhewitt davidhewitt requested a review from a team as a code owner July 16, 2025 12:39
@@ -104,10 +105,10 @@ let counter = meter.u64_counter("my_counter").build();
- Replaced `global::meter_with_version` with `global::meter_with_scope`
- Added `global::tracer_with_scope`
- Refer to PR description for migration guide.
- **Breaking change**: replaced `InstrumentationScope` public attributes by getters [#2275](https://github.com/open-telemetry/opentelemetry-rust/pull/2275)
Copy link
Author

Choose a reason for hiding this comment

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

Sorry for the whitespace stripped in this file by my editor, let me know if this needs reverting.

@davidhewitt davidhewitt changed the title add methods to get Resource set on in memory exporters feat: add methods to get Resource set on in memory exporters Jul 16, 2025
Copy link

codecov bot commented Jul 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.2%. Comparing base (0e3511e) to head (e3c0b07).

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #3070   +/-   ##
=====================================
  Coverage   80.1%   80.2%           
=====================================
  Files        126     126           
  Lines      21949   21979   +30     
=====================================
+ Hits       17603   17634   +31     
+ Misses      4346    4345    -1     

☔ 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.

@cijothomas
Copy link
Member

https://github.com/open-telemetry/opentelemetry-rust/blob/main/opentelemetry-sdk/src/logs/mod.rs#L119
One can indirectly validate that resource is setup correctly, as the exported telemetry is associated with the Resource and can catch issues like processor not passing Resource to exporter.

This is a small change, so I am okay with it. Please see if the above solves the issue you are trying to address and the PR is really needed.

@cijothomas
Copy link
Member

Same/similar issue was reported #3068 (comment) too.

@davidhewitt
Copy link
Author

Thanks for the review. So I think the confusion I had is that InMemorySpanExporter just emits SpanData which does not seems to have an associated resource. So this differs from InMemoryLogExporter, where there is already a solution as you show.

So I guess either we merge this to make it possible to access the resource in this (same) new way in both, or we should change to produce SpanDataWithResource and associate the resource that way?

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.

2 participants