Skip to content

feat(sdk-metrics): add MeterConfigurator support - #7018

Open
Ayushgupta2408 wants to merge 1 commit into
open-telemetry:mainfrom
Ayushgupta2408:feat/sdk-metrics-meter-configurator
Open

feat(sdk-metrics): add MeterConfigurator support#7018
Ayushgupta2408 wants to merge 1 commit into
open-telemetry:mainfrom
Ayushgupta2408:feat/sdk-metrics-meter-configurator

Conversation

@Ayushgupta2408

Copy link
Copy Markdown

Fixes #6952

sdk-metrics currently has no way to configure per-meter behavior at
runtime — the MeterConfigurator concept described in the metrics SDK
spec

is not implemented. sdk-logs already implements the equivalent
LoggerConfigurator (#5991); this PR ports that pattern to sdk-metrics.

Short description of the changes

  • Adds MeterConfig (packages/sdk-metrics/src/MeterConfig.ts): currently
    a single disabled?: boolean field, matching the spec's minimal
    MeterConfig definition.
  • Adds MeterConfigurator type and createMeterConfigurator() helper
    (packages/sdk-metrics/src/MeterConfigurator.ts): builds a configurator
    from an ordered list of { name, config } conditions, matching meter
    names by exact string or *-wildcard pattern (first match wins).
  • Wires the configurator through the existing meter-creation path:
    • MeterProviderSharedState now accepts an optional meterConfigurator
      and computes the MeterConfig for a scope in getMeterSharedState().
    • MeterSharedState's constructor now accepts and forwards that
      MeterConfig to Meter.
    • Meter stores the resolved config and, when disabled: true, returns
      the no-op instrument (createNoopMeter()) from every create*
      instrument method and no-ops addBatchObservableCallback, instead of
      registering real storage.
  • MeterProviderOptions.meterConfigurator (already present on the
    interface) is now actually passed through to MeterProviderSharedState
    — previously it was accepted but silently ignored.
  • Exports MeterConfig, MeterConfigurator, MeterConfiguratorCondition,
    and createMeterConfigurator from the package's public index.ts.
  • Adds test/MeterConfigurator.test.ts covering:
    • exact-name match, wildcard match, first-match-wins with multiple
      conditions, and no-match → null
    • end-to-end: a MeterProvider configured with a disabled pattern
      produces no recorded data points for matching meters while unrelated
      meters record normally.

Type of change

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • 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?

  • npx tsc -p tsconfig.json --noEmit — passes with no errors.
  • npx nx run sdk-metrics:lint — passes.
  • npx nx run sdk-metrics:test — new MeterConfigurator.test.ts suite
    passes alongside the existing sdk-metrics test suite.
  • Manually verified that a MeterProvider without a meterConfigurator
    behaves identically to before (backward compatible — meterConfig
    defaults to undefinedDEFAULT_METER_CONFIGdisabled: false).

Checklist:

  • Followed the style guidelines of this project
  • Changelog entry added (CHANGELOG.md)
  • Unit tests have been added
  • Documentation has been updated (packages/sdk-metrics/README.md)

Signed-off-by: Ayush kumar gupta <ag5510362@gmail.com>
@Ayushgupta2408
Ayushgupta2408 requested a review from a team as a code owner August 22, 2026 07:59
@linux-foundation-easycla

linux-foundation-easycla Bot commented Aug 22, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: Ayushgupta2408 / name: Ayush kumar gupta (96b4dd8)

@github-actions

Copy link
Copy Markdown

Welcome, contributor! Thank you for your contribution to opentelemetry-js.

Important reminders:

@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Aug 22, 2026

Copy link
Copy Markdown

Pull request dashboard status

Waiting on reviewers · refreshed 2026-08-22 08:02 UTC

Review the latest changes.

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.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

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.

[sdk-metrics] support MeterConfigurator

1 participant