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

Fix: filter exemplar for observable instrument and export of exemplar without trace and span ids #4251

Merged
merged 15 commits into from
Nov 8, 2024

Conversation

fcollonval
Copy link
Contributor

@fcollonval fcollonval commented Nov 6, 2024

Description

Fixes #4250

  • It applies correctly the exemplar filter to the observable instruments
  • It does not export the trace_id and span_id attributes of exemplars if undefined
  • It fixes the type of trace_id and span_id in exemplar classes

The two latter fixes were extracted from #4178

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Check example docs/examples/metrics/instruments/example.py
  • Add tests by @xrmx in exporter/opentelemetry-exporter-otlp-proto-common/tests/test_metrics_encoder.py
  • Extend test to check consume_measurement is called with exemplar filter result for async instrument

Does This PR Require a Contrib Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@fcollonval fcollonval changed the title Fix/exemplar-sampling-export Fix: filter exemplar for observable instrument and export of exemplar without trace and span ids Nov 6, 2024
@fcollonval
Copy link
Contributor Author

Thanks @xrmx for the quick review - I don't know what to do about the remaining failure for the generate-workflows job.

@fcollonval fcollonval marked this pull request as ready for review November 6, 2024 15:46
@fcollonval fcollonval requested a review from a team as a code owner November 6, 2024 15:46
@emdneto
Copy link
Member

emdneto commented Nov 6, 2024

Thanks @xrmx for the quick review - I don't know what to do about the remaining failure for the generate-workflows job.

We need to update the workflows. I can fix it for you. It seems we have another issue with internal generate-workflows-lib. Fix here open-telemetry/opentelemetry-python-contrib#2964

@emdneto emdneto added sdk Affects the SDK package. metrics labels Nov 6, 2024
@xrmx xrmx mentioned this pull request Nov 6, 2024
11 tasks
Copy link
Member

@aabmass aabmass left a comment

Choose a reason for hiding this comment

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

Change LGTM but can you add an integration test case for this bug? Here's an existing test you could model it after https://github.com/open-telemetry/opentelemetry-python/blob/main/opentelemetry-sdk/tests/metrics/integration_test/test_disable_default_views.py

@emdneto emdneto force-pushed the fix/exemplar-sampling-export branch from 14cbf8f to 298cc1e Compare November 6, 2024 19:50
@xrmx
Copy link
Contributor

xrmx commented Nov 7, 2024

@fcollonval I think we are also missing tests for the OTEL_METRICS_EXEMPLAR_FILTER env var, when I set
OTEL_METRICS_EXEMPLAR_FILTER=always_off, the correct sampler is set but I get exemplars in the exported metrics but this is fixed by this PR too.

UPDATE: maybe the test requested by Aaron is enough

@xrmx
Copy link
Contributor

xrmx commented Nov 7, 2024

I've started writing some integration tests but the always_off and trace_based are wrong because there should be an exemplar in the trace_based one:
056313c

@xrmx xrmx requested a review from aabmass November 8, 2024 09:24
@xrmx
Copy link
Contributor

xrmx commented Nov 8, 2024

@aabmass Emidio fixed tests PTAL

@xrmx xrmx merged commit c4fa8d7 into open-telemetry:main Nov 8, 2024
353 checks passed
lzchen pushed a commit that referenced this pull request Nov 8, 2024
… without trace and span ids (#4251)

* Deal with missing span and trace ids

* Fix applying exemplar filter to observable instruments

* Lint the code

* add tests

* Add entry in changelog

* Fix span and trace id typing

* Fix CI

* Test consume_measurement is called for async instrument

* Add integration tests

* fix integration tests

Signed-off-by: emdneto <[email protected]>

* Update opentelemetry-sdk/tests/metrics/integration_test/test_exemplars.py

* add test that default exemplar filter with no span does not create exemplar

---------

Signed-off-by: emdneto <[email protected]>
Co-authored-by: Frédéric Collonval <[email protected]>
Co-authored-by: Riccardo Magliocchetti <[email protected]>
Co-authored-by: Emídio Neto <[email protected]>
Co-authored-by: Aaron Abbott <[email protected]>
@fcollonval fcollonval deleted the fix/exemplar-sampling-export branch November 9, 2024 14:30
@fcollonval
Copy link
Contributor Author

fcollonval commented Nov 9, 2024

Thanks a lot to all of you for helping fixing this and more generally for the maintenance of this great repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
metrics sdk Affects the SDK package.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Metrics exporting without a trace regression in 1.28.0
5 participants