@@ -15,26 +15,7 @@ Use the appropriate semconv attribute modules — do not hardcode attribute name
1515- ` error.* ` attributes: ` opentelemetry.semconv.attributes.error_attributes `
1616- Other namespaces: use the corresponding module from ` opentelemetry.semconv `
1717
18- ## 2. TelemetryHandler Initialization
19-
20- Construct ` TelemetryHandler ` once per instrumentor, passing the OTel providers and the
21- completion hook. Always resolve the hook with `kwargs.get("completion_hook") or
22- load_completion_hook()` so callers can inject a hook directly, and fall back to the
23- entry-point-loaded hook configured via ` OTEL_INSTRUMENTATION_GENAI_COMPLETION_HOOK ` .
24-
25- ``` python
26- from opentelemetry.util.genai.completion_hook import load_completion_hook
27- from opentelemetry.util.genai.handler import TelemetryHandler
28-
29- handler = TelemetryHandler(
30- tracer_provider = tracer_provider,
31- meter_provider = meter_provider,
32- logger_provider = logger_provider,
33- completion_hook = kwargs.get(" completion_hook" ) or load_completion_hook(),
34- )
35- ```
36-
37- ## 3. Invocation Lifecycle Pattern
18+ ## 2. Invocation Lifecycle Pattern
3819
3920Every new operation type must follow this pattern:
4021
@@ -67,21 +48,21 @@ Context manager equivalents (`handler.inference()`, `handler.embedding()`, `hand
6748etc.) in instrumentation or production code — direct construction skips span creation and context
6849propagation, so all telemetry calls become no-ops. Always use ` handler.start_*() ` .
6950
70- ## 4 . Exception Handling
51+ ## 3 . Exception Handling
7152
7253- Do not add ` raise {Error} ` statements to ` handler.py ` or ` types.py ` — validation belongs in
7354 tests and callers, not telemetry internals.
7455- When catching exceptions from the underlying library to record telemetry, always re-raise
7556 the original exception unmodified.
7657
77- ## 5 . Documentation
58+ ## 4 . Documentation
7859
7960- Docstrings for invocation types and span/event helpers must include a link to the
8061 corresponding operation in the semconv spec.
8162- When adding or changing attributes, update the docstring to describe what is set and under
8263 what conditions (e.g., "set only when ` server_address ` is provided").
8364
84- ## 6 . Tests
65+ ## 5 . Tests
8566
8667- Every new operation type or attribute change must have tests verifying the exact attribute
8768 names and values produced, checked against the semconv spec.
@@ -90,7 +71,7 @@ propagation, so all telemetry calls become no-ops. Always use `handler.start_*()
9071- Tests live in ` tests/ ` — follow existing patterns there.
9172- Don't call internal API in tests when the public API is available.
9273
93- ## 7 . Python API Conventions
74+ ## 6 . Python API Conventions
9475
9576- Mark private modules with an underscore.
9677- Objects inside of a private module should be prefixed with underscopre if they
0 commit comments