loongsuite-util-genai
LoongSuite GenAI Utils
What it is and what it does
loongsuite-util-genai is an extension of OpenTelemetry's GenAI semantic conventions, designed to capture observability data from large language model calls, agent orchestration, vector retrieval, tool execution, and related AI workflows. It provides a unified telemetry handler that maps these operations into standardized OpenTelemetry Spans with semantic attributes, optional structured events, and configurable message content capture. The package imports as opentelemetry.util.genai but is distributed as loongsuite-util-genai to avoid conflicts with the upstream community package.
The handler supports LLM chat/completion calls with multimodal message handling, agent creation and invocation, embedding operations, tool execution with skill metadata, retrieval and reranking, memory operations, application entry points with session/user ID propagation via Baggage, and ReAct iteration tracking. Message content (prompts, responses) is not captured by default to protect sensitive data and reduce trace volume; it must be explicitly enabled via environment variables. The package integrates with OpenTelemetry's standard export pipeline and is designed to work with auto-instrumentation frameworks or direct SDK initialization.
Use it for:
- Trace LLM API calls end-to-end with standardized span attributes, token counts, and model metadata for debugging and performance monitoring.
- Monitor agent orchestration workflows by capturing agent creation, invocation, tool execution, and memory operations as linked spans.
- Observe vector retrieval and reranking operations within RAG pipelines to identify latency and quality bottlenecks.
- Correlate user sessions and requests across distributed AI services using Baggage-based span coloring at application entry points.
- Audit LLM inputs and outputs by enabling structured event capture with full message content when compliance or debugging requires it.
- Integrate GenAI telemetry into existing OpenTelemetry observability stacks (Jaeger, Datadog, Honeycomb, etc.) without custom instrumentation.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Extends OpenTelemetry's GenAI semantic conventions to capture telemetry from large language models, agents, tool calls, vector retrieval, and related operations, mapping them to standardized Span attributes, optional message content, and GenAI events.
Yes, if you are building AI applications with OpenTelemetry and need standardized tracing for LLMs, agents, and retrieval workflows. The package is actively maintained, has low install friction, and is Apache-2.0 licensed. Install via LoongSuite's recommended instrumentation chain to avoid dependency conflicts with the upstream package. Be aware that message content capture requires explicit environment variable configuration and that the extended semantic model for some scenarios (Agent, ReAct, memory) may still be evolving.
Install
loongsuite-util-genai on PyPI
pip
pip install loongsuite-util-genaiuv
uv add loongsuite-util-genaipoetry
poetry add loongsuite-util-genaiInstalling loongsuite-util-genai
Before you install
Low install friction with a pure-Python wheel and three lightweight OpenTelemetry runtime dependencies. Active maintenance as of 2026-08-13 with recent releases; part of a larger LoongSuite monorepo. Note: mixing this package with the upstream opentelemetry-util-genai can cause dependency resolution conflicts—prefer installing via LoongSuite's recommended instrumentation chain.
License in practice
Licensed under Apache-2.0 (permissive), allowing commercial and private use with minimal restrictions. No license-related barriers to adoption.
Quickstart
pip install loongsuite-util-genai
from opentelemetry import trace
from opentelemetry.util.genai.extended_handler import get_extended_telemetry_handler
from opentelemetry.util.genai.types import InputMessage, LLMInvocation, OutputMessage, Text
handler = get_extended_telemetry_handler()
invocation = LLMInvocation(
provider="openai",
request_model="gpt-4o-mini",
input_messages=[InputMessage(role="user", parts=[Text(content="Hello")])],
)
with handler.llm(invocation) as inv:
inv.output_messages = [OutputMessage(role="assistant", parts=[Text(content="Hi")], finish_reason="stop")]
inv.input_tokens = 10
inv.output_tokens = 20
Requires Python 3.9 or later. Global TracerProvider, MeterProvider, and LoggerProvider must be initialized before calling get_extended_telemetry_handler()—either via OpenTelemetry auto-instrumentation or explicit SDK setup. Message content capture requires environment variables OTEL_SEMCONV_STABILITY_OPT_IN and OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT to be configured.
Verify before relying
- Whether the package's extended semantic model for Agent, retrieval, memory, and ReAct scenarios is stable or still experimental.
- Performance overhead of message content capture modes (SPAN_ONLY, EVENT_ONLY, SPAN_AND_EVENT) at scale.
- Compatibility guarantees with upstream opentelemetry-util-genai API changes.
- Whether external storage and URI replacement for multimodal messages is production-ready.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — opentelemetry-api, opentelemetry-instrumentation, opentelemetry-semantic-conventions |
| Maintenance | actively maintained — 95 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 4,315,183/month — #2,331 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: loongsuite_util_genai-0.5.0-py3-none-any.whl
Tags
More Monitoring packages
Wraps any iterable to display a real-time…
copyleft · top 100 on PyPI
opentelemetry-semantic-conventionsProvides generated Python code for…
permissive · top 100 on PyPI
opentelemetry-sdkProvides the reference implementation of the…
permissive · top 100 on PyPI
opentelemetry-apiProvides the abstract API and interfaces for…
permissive · top 100 on PyPI
opentelemetry-exporter-otlp-proto-httpExports OpenTelemetry observability data to an…
permissive · top 1,000 on PyPI
opentelemetry-instrumentationProvides automatic instrumentation commands and…
permissive · top 1,000 on PyPI
opentelemetry-util-genaiProvides standardized instrumentation utilities…
permissive · top 5,000 on PyPI
opentelemetry-instrumentation-openai-v2Automatically traces and logs OpenAI API calls…
permissive · top 5,000 on PyPI
opentelemetry-instrumentation-google-genaiAdds OpenTelemetry instrumentation to the…
permissive · top 5,000 on PyPI
aliyun-semantic-conventionsProvides standardized semantic convention…
permissive · top 5,000 on PyPI
openinference-instrumentation-google-genaiAutomatically instruments Google GenAI SDK…
permissive · top 15,000 on PyPI
opentelemetry-semantic-conventions-aiProvides OpenTelemetry semantic conventions and…
permissive · top 1,000 on PyPI
opentelemetry-instrumentation-openai-agentsAdds distributed tracing to OpenAI Agents…
permissive · top 5,000 on PyPI
microsoft-agents-a365-observability-coreProvides OpenTelemetry-based telemetry,…
permissive · top 15,000 on PyPI
opentelemetry-instrumentation-google-generativeaiAutomatically traces prompts, completions, and…
permissive · top 5,000 on PyPI
openinference-instrumentation-portkeyAutomatically instruments Portkey AI API calls…
permissive · top 15,000 on PyPI