Skip to content

Commit 372e1a5

Browse files
committed
feat: otlp http exporter
1 parent 02aee9c commit 372e1a5

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

‎pyproject.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ dependencies = [
1616
"pydantic~=2.12.3",
1717
"hatchling~=1.27.0",
1818
"opentelemetry-exporter-otlp-proto-grpc~=1.38.0",
19+
"opentelemetry-exporter-otlp-proto-http~=1.38.0",
1920
"traceloop-sdk~=0.52.0"
2021
]
2122

‎src/sap_cloud_sdk/core/telemetry/auto_instrument.py‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import logging
22
import os
33

4-
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
54
from opentelemetry.sdk.trace.export import ConsoleSpanExporter
65
from traceloop.sdk import Traceloop
76

@@ -41,7 +40,25 @@ def auto_instrument():
4140
else:
4241
if "v1/traces" not in otel_endpoint:
4342
otel_endpoint = otel_endpoint.rstrip("/") + "/v1/traces"
44-
logger.info(f"Initializing auto instrumentation with endpoint: {otel_endpoint}")
43+
protocol = os.getenv("OTEL_EXPORTER_OTLP_PROTOCOL", "grpc").lower()
44+
if protocol == "grpc":
45+
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import (
46+
OTLPSpanExporter,
47+
)
48+
elif protocol == "http/protobuf":
49+
from opentelemetry.exporter.otlp.proto.http.trace_exporter import (
50+
OTLPSpanExporter,
51+
)
52+
else:
53+
raise ValueError(
54+
f"Unsupported OTEL_EXPORTER_OTLP_PROTOCOL: '{protocol}'. "
55+
"Supported values are 'grpc' and 'http/protobuf'."
56+
)
57+
58+
logger.info(
59+
f"Initializing auto instrumentation with endpoint: {otel_endpoint} "
60+
f"(protocol: {protocol})"
61+
)
4562
base_exporter = OTLPSpanExporter(endpoint=otel_endpoint)
4663

4764
exporter = GenAIAttributeTransformer(base_exporter)

‎uv.lock‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)