Skip to content

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

@bbckr

Description

@bbckr

Problem Statement

When configuring telemetry and setting up the meter similar to:

from strands.telemetry import StrandsTelemetry
strands_telemetry = StrandsTelemetry()
strands_telemetry.setup_otlp_exporter()
strands_telemetry.setup_meter(enable_otlp_exporter=True)

I want to be able to pass views to StrandsTelemetry.setup_meter(), as this cannot be configured unless I explicitly set strands_telemetry.meter_provider myself similar to how StrandsTelemetry.setup_meter already does it.

Proposed Solution

I propose StrandsTelemetry.setup_meter() includes an optional argument for views, so that the metric provider configures the views alongside the readers its already configuring.

from strands.telemetry import StrandsTelemetry

views = [
  View(instrument_name="*", aggregation=DropAggregation()),
  View(instrument_name="mycounter"),
]

strands_telemetry = StrandsTelemetry()
strands_telemetry.setup_otlp_exporter()
strands_telemetry.setup_meter(enable_otlp_exporter=True, views=views) # the proposed change

Use Case

I need to filter out certain tags we do not need (like tool_use_id and event_loop_cycle_id) that are high-cardinality and would like to increased custom metric costs with vendors like Datadog.

Alternatives Solutions

No response

Additional Context

Let me know what you all think and (if needed) I can open the PR myself for the change.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions