Skip to content

Commit 304c426

Browse files
committed
Support exporter protocol
1 parent ff0c46e commit 304c426

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/langtrace_python_sdk/langtrace.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ def __init__(self, **kwargs):
9999
or os.environ.get("LANGTRACE_HEADERS")
100100
or os.environ.get("OTEL_EXPORTER_OTLP_HEADERS")
101101
)
102-
self.session_id = kwargs.get("session_id") or os.environ.get("LANGTRACE_SESSION_ID")
102+
self.session_id = kwargs.get("session_id") or os.environ.get(
103+
"LANGTRACE_SESSION_ID"
104+
)
103105

104106

105107
def get_host(config: LangtraceConfig) -> str:
@@ -156,9 +158,16 @@ def get_exporter(config: LangtraceConfig, host: str):
156158
return config.custom_remote_exporter
157159

158160
headers = get_headers(config)
159-
host = f"{host}/api/trace" if host == LANGTRACE_REMOTE_URL else host
160-
if "http" in host.lower() or "https" in host.lower():
161-
return HTTPExporter(endpoint=host, headers=headers)
161+
exporter_protocol = os.environ.get("OTEL_EXPORTER_OTLP_PROTOCOL", "http")
162+
if "http" in exporter_protocol.lower():
163+
return HTTPExporter(
164+
endpoint=(
165+
f"{host}/api/trace"
166+
if host == LANGTRACE_REMOTE_URL
167+
else f"{host}/v1/traces"
168+
),
169+
headers=headers,
170+
)
162171
else:
163172
return GRPCExporter(endpoint=host, headers=headers)
164173

0 commit comments

Comments
 (0)