Skip to content

Commit 8e5c6ab

Browse files
committed
update file doc strings
1 parent 5cea4a6 commit 8e5c6ab

File tree

2 files changed

+22
-25
lines changed

2 files changed

+22
-25
lines changed

util/opentelemetry-util-genai/src/opentelemetry/util/genai/generators.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,22 @@
1313
# limitations under the License.
1414

1515
"""
16-
Emitters for GenAI telemetry instrumentation.
16+
Span generation utilities for GenAI telemetry.
1717
18-
This module defines classes and utilities for mapping GenAI (Generative AI) invocations
19-
to OpenTelemetry spans, metrics, and events. Emitters manage the lifecycle of telemetry
20-
data for LLM (Large Language Model) operations, including success and error reporting.
18+
This module maps GenAI (Generative AI) invocations to OpenTelemetry spans and
19+
applies GenAI semantic convention attributes.
2120
2221
Classes:
23-
BaseEmitter: Abstract base class for GenAI telemetry emitters.
24-
SpanMetricEventEmitter: Emits spans, metrics, and events for full telemetry.
25-
SpanMetricEmitter: Emits only spans and metrics (no events).
26-
27-
Functions:
28-
_get_property_value: Utility to extract property values from objects or dicts.
29-
_message_to_log_record: Converts a GenAI message to an OpenTelemetry LogRecord.
30-
_chat_generation_to_log_record: Converts a chat generation to a LogRecord.
31-
_get_metric_attributes: Builds metric attributes for telemetry reporting.
32-
22+
- BaseTelemetryGenerator: Abstract base for GenAI telemetry emitters.
23+
- SpanGenerator: Concrete implementation that creates and finalizes spans
24+
for LLM operations (e.g., chat) and records input/output messages when
25+
experimental mode and content capture settings allow.
26+
27+
Usage:
28+
See `opentelemetry/util/genai/handler.py` for `TelemetryHandler`, which
29+
constructs `LLMInvocation` objects and delegates to `SpanGenerator.start`,
30+
`SpanGenerator.finish`, and `SpanGenerator.error` to produce spans that
31+
follow the GenAI semantic conventions.
3332
"""
3433

3534
import json

util/opentelemetry-util-genai/src/opentelemetry/util/genai/handler.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,21 @@
1515
"""
1616
Telemetry handler for GenAI invocations.
1717
18-
This module provides the `TelemetryHandler` class, which manages the lifecycle of
19-
GenAI (Generative AI) invocations and emits telemetry data as spans, metrics, and events.
20-
It supports starting, stopping, and failing LLM invocations,
21-
and provides module-level convenience functions for these operations.
18+
This module exposes the `TelemetryHandler` class, which manages the lifecycle of
19+
GenAI (Generative AI) invocations and emits telemetry data (spans and related attributes).
20+
It supports starting, stopping, and failing LLM invocations.
2221
2322
Classes:
24-
TelemetryHandler: Manages GenAI invocation lifecycles and emits telemetry.
23+
- TelemetryHandler: Manages GenAI invocation lifecycles and emits telemetry.
2524
2625
Functions:
27-
get_telemetry_handler: Returns a singleton TelemetryHandler instance.
28-
llm_start: Starts a new LLM invocation.
29-
llm_stop: Stops an LLM invocation and emits telemetry.
30-
llm_fail: Marks an LLM invocation as failed and emits error telemetry.
26+
- get_telemetry_handler: Returns a singleton `TelemetryHandler` instance.
3127
3228
Usage:
33-
Use the module-level functions (`llm_start`, `llm_stop`, `llm_fail`) to
34-
instrument GenAI invocations for telemetry collection.
29+
handler = get_telemetry_handler()
30+
handler.start_llm(prompts, run_id, system="provider-name", **attrs)
31+
handler.stop_llm(run_id, chat_generations, **attrs)
32+
handler.fail_llm(run_id, error, **attrs)
3533
"""
3634

3735
import time

0 commit comments

Comments
 (0)