feat: Add HTTP OTLP trace exporter support for auto instrumentation#18
feat: Add HTTP OTLP trace exporter support for auto instrumentation#18
Conversation
|
hope seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
| if protocol == "grpc": | ||
| from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import ( | ||
| OTLPSpanExporter, | ||
| ) | ||
| elif protocol == "http/protobuf": | ||
| from opentelemetry.exporter.otlp.proto.http.trace_exporter import ( | ||
| OTLPSpanExporter, | ||
| ) |
There was a problem hiding this comment.
The lazy import approach works, but I'd suggest moving the imports to the top level instead.
Top-level imports are the standard Python convention (PEP 8) and make the dependencies of the module immediately visible to readers.
Since both opentelemetry-exporter-otlp-proto-grpc and opentelemetry-exporter-otlp-proto-http are declared as required dependencies in pyproject.toml, they will always be present, so we don't need to defer the import. Lazy imports are a useful pattern when a dependency is optional or heavy to load, but neither applies here.
There was a problem hiding this comment.
By the way I like the idea of raising a ValueError.
Description
This PR introduces support for selecting the OTLP exporter protocol based on the
OTEL_EXPORTER_OTLP_PROTOCOLenvironment variable, enabling users to choose between gRPC and HTTP/protobuf transports for telemetry data export. The default will be gRPC if the variable is not set, ensuring backward compatibility.Related Issue
Closes #17
Type of Change
Please check the relevant option:
How to Test
Describe how reviewers can test your changes:
OTEL_EXPORTER_OTLP_PROTOCOL="http/protobuf"Checklist
Before submitting your PR, please review and check the following: