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.3.tar.gz.

File metadata

File hashes

Hashes for splunk_otel_util_genai_translator_traceloop-0.1.3.tar.gz
Algorithm Hash digest
SHA256 aa9bb7e2ad9c2018ce9cc767d1dffce046e255a84296b6582564b79aa2ab3e21
MD5 b158acf12dc6efab1949a9caad12f90c
BLAKE2b-256 a243045ea7e1402c9f78cd846deb9042e505671a19c7eec6d24b7a9d80301879

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for splunk_otel_util_genai_translator_traceloop-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7a8f16481b81016f7056ab5f54b3c00a7db60835441b042f313e47326aa3e9ac
MD5 b152575631995ee231ecd468dd79397b
BLAKE2b-256 fe6a20479ee8ad851b6de76ce7291f69751554b0d2940053a0b7dbf3f15c197e

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