Skip to content

[Don't merge][WIP][Prototype] Add Python instrumentation Labeler #3689

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

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

tammy-baylis-swi
Copy link
Contributor

@tammy-baylis-swi tammy-baylis-swi commented Aug 13, 2025

Description

Adds new a Python instrumentation Labeler, inspired by Go's net/http instrumentation: open-telemetry/opentelemetry-go-contrib#306. It stores KVs added to it in the current context. The add / add_attributes can be called by user's instrumented code manually, or by custom distros.

Labeler can be read by existing instrumentors so that any added KVs are merged into the attributes of metrics being written. In this PR, FlaskInstrumentor does this so that custom attributes are added to the record calls of the new and old duration histograms.

Addresses #3702, #3703

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

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

  • New unit tests
  • Local installation and manual instrumentation of Flask app, as per new doc

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

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

@tammy-baylis-swi tammy-baylis-swi force-pushed the add-metrics-attributes-labeler branch from d676f55 to 6cec2f1 Compare August 20, 2025 22:54
@tammy-baylis-swi tammy-baylis-swi force-pushed the add-metrics-attributes-labeler branch from 6cec2f1 to ce12b1b Compare August 20, 2025 22:55
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.

1 participant