feat(telemetry): support gRPC transport for OTLP exporters#2325
Open
aribault wants to merge 2 commits into
Open
feat(telemetry): support gRPC transport for OTLP exporters#2325aribault wants to merge 2 commits into
aribault wants to merge 2 commits into
Conversation
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
setup_otlp_exporter and setup_meter previously hard-coded the HTTP variant
of OTLPSpanExporter and OTLPMetricExporter, leaving users who need gRPC
(common with OpenTelemetry Collector and several vendor agents) no choice
but to bypass the helpers and reconstruct the providers manually.
Both methods now accept a protocol parameter ("http/protobuf" or "grpc"),
falling back to the standard OTEL_EXPORTER_OTLP_PROTOCOL env var, then to
http/protobuf. The gRPC dependency lives in a new opt-in 'otel-grpc' extra
so existing 'otel' installs are unchanged in size and behavior.
Resolves: strands-agents#689
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
StrandsTelemetry.setup_otlp_exporterand the OTLP-metrics path insidesetup_meterhard-code the HTTP variant ofOTLPSpanExporter/OTLPMetricExporter. Users running their telemetry through the OpenTelemetry Collector (or vendor agents that prefer gRPC) currently have to bypass the helpers entirely and reconstruct the providers themselves.This change adds first-class gRPC support while keeping HTTP as the default, matching
Unshure's direction in #689.Resolves: #689
Public API Changes
setup_otlp_exporternow accepts aprotocolparameter, andsetup_meteracceptsotlp_protocol. Resolution order is explicit arg →OTEL_EXPORTER_OTLP_PROTOCOLenv var →http/protobuf(matching the OTel SDK convention). When\"grpc\"is selected and the optional dependency is missing, anImportErrorsurfaces apip installhint pointing at the newotel-grpcextra.New Optional Dependency
A new
otel-grpcextra inpyproject.toml:The existing
otelextra is untouched (HTTP-only). Users opt into gRPC explicitly viapip install 'strands-agents[otel-grpc]'. Theallmeta-extra now includesotel-grpcso users on[all]get both transports.Existing callers (no
protocolargument,otelextra installed) keep their previous behavior with no install-size growth.