Skip to content

feat(telemetry): forward provider_kwargs to MeterProvider in setup_meter#2324

Open
aribault wants to merge 1 commit into
strands-agents:mainfrom
aribault:feat/telemetry-meter-provider-kwargs
Open

feat(telemetry): forward provider_kwargs to MeterProvider in setup_meter#2324
aribault wants to merge 1 commit into
strands-agents:mainfrom
aribault:feat/telemetry-meter-provider-kwargs

Conversation

@aribault
Copy link
Copy Markdown

@aribault aribault commented May 25, 2026

Motivation

StrandsTelemetry.setup_meter constructs an OpenTelemetry MeterProvider but only forwards resource and metric_readers. Users who need to pass other supported MeterProvider kwargs, most notably views, currently have to bypass setup_meter entirely and reconstruct the provider from scratch, as illustrated in the workaround the issue reporter shared.

This change accepts arbitrary keyword arguments and forwards them to MeterProvider, exposing the full surface without changing any existing behavior.

Resolves: #843

Public API Changes

setup_meter now accepts **provider_kwargs that are forwarded to MeterProvider. resource and metric_readers continue to be managed by the helper.

# Before — had to bypass setup_meter to attach views
meter_provider = MeterProvider(
    resource=resource,
    metric_readers=metrics_readers,
    views=[View(instrument_name="strands.tool.*", attribute_keys={"tool_name"})],
)
strands_telemetry.meter_provider = meter_provider
metrics_api.set_meter_provider(meter_provider)

# After
strands_telemetry.setup_meter(
    enable_otlp_exporter=True,
    views=[View(instrument_name="strands.tool.*", attribute_keys={"tool_name"})],
)

Existing callers are unaffected.

@aribault aribault marked this pull request as ready for review May 25, 2026 20:06
setup_meter previously hard-coded the MeterProvider construction to only
accept resource and metric_readers, forcing users who needed views,
exemplar_filter, or shutdown_on_exit to bypass the helper entirely and
reconstruct the provider from scratch. This change accepts arbitrary
keyword arguments and forwards them, exposing the full MeterProvider
surface without changing existing behavior.

Resolves: strands-agents#843
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Support passing views to the meter provider created in StrandsTelemetry.setup_meter()

1 participant