Skip to content

opentelemetry-api: implement metrics bind API - #5450

Open
herin049 wants to merge 11 commits into
open-telemetry:mainfrom
herin049:feat/instrument-bind
Open

herin049 wants to merge 11 commits into
open-telemetry:mainfrom
herin049:feat/instrument-bind

Conversation

@herin049

Copy link
Copy Markdown
Contributor

Description

Implements the OTel metrics Bind API.

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?

uv run tox -e py314-test-opentelemetry-api

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for “bound” synchronous metric instruments (per the OTel Metrics Bind concept), allowing instruments to be pre-associated with a set of attributes and to merge those attributes with per-call attributes at recording time.

Changes:

  • Adds _bind() to synchronous instrument types and introduces bound-instrument wrappers that delegate recording while merging/deepcopying attributes.
  • Adds API-level tests covering delegation behavior, attribute merging semantics, deepcopy behavior, rebinding flattening, and proxy instrument interaction.
  • Adds SDK-level tests validating that bound recordings flow through the measurement consumer and preserve existing validation behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
opentelemetry-api/src/opentelemetry/metrics/_internal/instrument.py Adds _bind() and bound instrument wrapper implementations for synchronous instruments.
opentelemetry-api/tests/metrics/test_instruments.py Adds API tests for bound instrument semantics (merge/deepcopy/rebind/proxy).
opentelemetry-sdk/tests/metrics/test_instrument.py Adds SDK tests to ensure bound instruments propagate measurements/validation correctly.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

Copy link
Copy Markdown

This PR has been automatically marked as stale because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 days of this comment.
If you're still working on this, please add a comment or push new commits.

@github-actions github-actions Bot added the Stale label Aug 14, 2026
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Aug 14, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Waiting on the author · refreshed 2026-10-26 20:54 UTC

Investigate required status check failures.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Should this be with reviewers? Comment /dashboard route:reviewers to route it to them.
  • Anything wrong — including the routing? Report it with what you expected; it helps us improve the dashboard.

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown

This PR has been automatically marked as stale because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 days of this comment.
If you're still working on this, please add a comment or push new commits.

@github-actions github-actions Bot added the Stale label Oct 2, 2026
@herin049 herin049 removed the Stale label Oct 5, 2026
@opentelemetry-pr-dashboard

Copy link
Copy Markdown

Hi @herin049 — just a friendly reminder that this pull request is waiting on you. The dashboard status comment has the open items and is kept current.

  • Replying is enough to hand it off — answer, explain why no change is needed, or ask a follow-up. The dashboard routes it onward once nothing on the list is waiting on you.
  • To hand it back for any other reason, including the dashboard getting this wrong, comment /dashboard route:reviewers.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants