forked from BerriAI/litellm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request BerriAI#4133 from BerriAI/litellm_work_with_tracep…
…arents [Feat] OTEL - allow propagating traceparent in headers
- Loading branch information
Showing
6 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
This file contains 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
41 changes: 41 additions & 0 deletions
41
litellm/proxy/tests/test_openai_request_with_traceparent.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# mypy: ignore-errors | ||
import openai | ||
from opentelemetry import trace | ||
from opentelemetry.context import Context | ||
from opentelemetry.trace import SpanKind | ||
from opentelemetry.sdk.trace import TracerProvider | ||
from opentelemetry.sdk.trace.export import SimpleSpanProcessor | ||
from opentelemetry.sdk.trace.export.in_memory_span_exporter import InMemorySpanExporter | ||
from opentelemetry.trace.propagation.tracecontext import TraceContextTextMapPropagator | ||
|
||
|
||
trace.set_tracer_provider(TracerProvider()) | ||
memory_exporter = InMemorySpanExporter() | ||
span_processor = SimpleSpanProcessor(memory_exporter) | ||
trace.get_tracer_provider().add_span_processor(span_processor) | ||
tracer = trace.get_tracer(__name__) | ||
|
||
# create an otel traceparent header | ||
tracer = trace.get_tracer(__name__) | ||
with tracer.start_as_current_span("ishaan-local-dev-app") as span: | ||