doc - OTEL trace propogation

This commit is contained in:
Ishaan Jaff 2024-06-11 14:25:33 -07:00
parent d829e6a297
commit d7f1445615
3 changed files with 67 additions and 0 deletions

View file

@ -0,0 +1,21 @@
# mypy: ignore-errors
import openai
import uuid
client = openai.OpenAI(api_key="sk-1234", base_url="http://0.0.0.0:4000")
example_traceparent = f"00-80e1afed08e019fc1110464cfa66635c-02e80198930058d4-01"
extra_headers = {"traceparent": example_traceparent}
_trace_id = example_traceparent.split("-")[1]
print("EXTRA HEADERS: ", extra_headers)
print("Trace ID: ", _trace_id)
response = client.chat.completions.create(
model="llama3",
messages=[
{"role": "user", "content": "this is a test request, write a short poem"}
],
extra_headers=extra_headers,
)
print(response)