Skip to main content

Traceloop -> GenAI translator emitter for OpenTelemetry GenAI

Project description

This package automatically translates Traceloop-instrumented spans into OpenTelemetry GenAI semantic conventions. It intercepts spans with traceloop.* attributes and creates corresponding spans with gen_ai.* attributes, enabling seamless integration between Traceloop instrumentation and GenAI observability tools.

Mapping Table

Traceloop Key

Added Key

traceloop.workflow.name

gen_ai.workflow.name

traceloop.entity.name

gen_ai.agent.name

traceloop.entity.path

gen_ai.workflow.path

traceloop.correlation.id

gen_ai.conversation.id

traceloop.entity.input

gen_ai.input.messages

traceloop.entity.output

gen_ai.output.messages

Installation

pip install opentelemetry-util-genai-traceloop-translator

Quick Start (Automatic Registration)

The easiest way to use the translator is to simply import it - no manual setup required!

import os
from openai import OpenAI


from traceloop.sdk import Traceloop
from traceloop.sdk.decorators import workflow

client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))

Traceloop.init(app_name="story_service")


@workflow(name="streaming_story")
def joke_workflow():
   stream = client.chat.completions.create(
      model="gpt-4o-2024-05-13",
      messages=[{"role": "user", "content": "Tell me a story about opentelemetry"}],
      stream=True,
   )

   for part in stream:
      print(part.choices[0].delta.content or "", end="")
   print()


joke_workflow()
# The translator automatically creates new gen_ai.* attributes based on the mapping.

Tests

pytest util/opentelemetry-util-genai-traceloop-translator/tests

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file splunk_otel_util_genai_translator_traceloop-0.1.4.tar.gz.

File metadata

File hashes

Hashes for splunk_otel_util_genai_translator_traceloop-0.1.4.tar.gz
Algorithm Hash digest
SHA256 01af92022a929619618d745f1f502cef18398b328aa7424263667d5a45ecb4db
MD5 56db8ea4e5c49e918ad83ab903d6b2f9
BLAKE2b-256 5c138cb21836a6540a953392541eda75e2dc4af3084b4dd7b711b06253bb419f

See more details on using hashes here.

File details

Details for the file splunk_otel_util_genai_translator_traceloop-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for splunk_otel_util_genai_translator_traceloop-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 49e38b681ee51ac5d2bde849be0a7835ad9778bcbd92f70ae64fddbb1d528903
MD5 0e5e0f1fbbd1c66a3b8a9e8b62a3f80a
BLAKE2b-256 eab9e465a476329cd2a877fd90eec3612e771fce71dd3cafe3389001fe8d9d5e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page