Skip to content

feat: Add HTTP OTLP trace exporter support for auto instrumentation#18

Open
hoperawr wants to merge 2 commits intoSAP:mainfrom
hoperawr:feat/auto-instrument-http
Open

feat: Add HTTP OTLP trace exporter support for auto instrumentation#18
hoperawr wants to merge 2 commits intoSAP:mainfrom
hoperawr:feat/auto-instrument-http

Conversation

@hoperawr
Copy link

Description

This PR introduces support for selecting the OTLP exporter protocol based on the OTEL_EXPORTER_OTLP_PROTOCOL environment 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:

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Code refactoring
  • Dependency update

How to Test

Describe how reviewers can test your changes:

  1. Add environment variable OTEL_EXPORTER_OTLP_PROTOCOL="http/protobuf"
  2. Use auto_instrument function
  3. Traces will be exported using HTTP protocol

Checklist

Before submitting your PR, please review and check the following:

  • I have read the Contributing Guidelines
  • I have verified that my changes solve the issue
  • I have added/updated automated tests to cover my changes
  • All tests pass locally
  • I have verified that my code follows the Code Guidelines
  • My code does not contain sensitive information (credentials, tokens, etc.)
  • I have followed Conventional Commits for commit messages

@hoperawr hoperawr requested a review from a team as a code owner March 25, 2026 07:18
@cla-assistant
Copy link

cla-assistant bot commented Mar 25, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


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.

@hoperawr hoperawr changed the title Add HTTP OTLP trace exporter support for auto instrumentation feat: Add HTTP OTLP trace exporter support for auto instrumentation Mar 25, 2026
Comment on lines +44 to +51
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,
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way I like the idea of raising a ValueError.

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.

Add HTTP OTLP Trace Exporter Support for Auto Instrumentation

2 participants