@@ -36,16 +36,16 @@ Factory methods on `TelemetryHandler` (`handler.py`):
3636
3737- ` start_inference(provider, request_model, *, server_address, server_port) ` → ` InferenceInvocation `
3838- ` start_embedding(provider, request_model, *, server_address, server_port) ` → ` EmbeddingInvocation `
39+ - ` start_tool(name, *, arguments, tool_call_id, tool_type, tool_description) ` → ` ToolInvocation `
3940- ` start_workflow(name) ` → ` WorkflowInvocation `
40- - For tool calls, construct ` ToolInvocation ` directly and call ` invocation.stop() ` / ` invocation.fail(exc) `
4141
42- Context manager equivalents (` handler.inference() ` , ` handler.embedding() ` , ` handler.workflow () ` ) are
43- available when the span lifetime maps cleanly to a ` with ` block.
42+ Context manager equivalents (` handler.inference() ` , ` handler.embedding() ` , ` handler.tool () ` ,
43+ ` handler.workflow() ` ) are available when the span lifetime maps cleanly to a ` with ` block.
4444
4545### Anti-patterns
4646
47- ** Never construct invocation types directly** (` WorkflowInvocation (...)` , etc.) in
48- instrumentation or production code — direct construction skips span creation and context
47+ ** Never construct invocation types directly** (` InferenceInvocation (...)` , ` ToolInvocation(...) ` ,
48+ etc.) in instrumentation or production code — direct construction skips span creation and context
4949propagation, so all telemetry calls become no-ops. Always use ` handler.start_*() ` .
5050
5151## 3. Exception Handling
@@ -56,26 +56,25 @@ propagation, so all telemetry calls become no-ops. Always use `handler.start_*()
5656 the original exception unmodified.
5757- Do not wrap, replace, or suppress exceptions — telemetry must be transparent to callers.
5858
59- ## 3 . Documentation
59+ ## 4 . Documentation
6060
6161- Docstrings for invocation types and span/event helpers must include a link to the
6262 corresponding operation in the semconv spec.
6363- When adding or changing attributes, update the docstring to describe what is set and under
6464 what conditions (e.g., "set only when ` server_address ` is provided").
6565
66- ## 4 . Tests
66+ ## 5 . Tests
6767
6868- Every new operation type or attribute change must have tests verifying the exact attribute
6969 names and values produced, checked against the semconv spec.
7070- Cover all paths: success (` invocation.stop() ` ), failure (` invocation.fail(exc) ` ), and any
7171 conditional attribute logic (e.g., attributes set only when optional fields are populated).
7272- Tests live in ` tests/ ` — follow existing patterns there.
73- - Don't call internal API in testswhen the public API is available.
73+ - Don't call internal API in tests when the public API is available.
7474
75- ## 5 . Python API Conventions
75+ ## 6 . Python API Conventions
7676
7777- Mark internal class methods, instance fields, and module-level helpers with a ` _ ` prefix;
7878 anything without it is considered public API.
79- - Use ` field(init=False) ` for fields set internally after construction.
8079- Before removing or renaming a public symbol, deprecate it first with
81- ` warnings.warn( ..., DeprecationWarning, stacklevel=2 )` pointing to the replacement;
80+ ` @deprecated(" ... Use X instead." )` pointing to the replacement;
0 commit comments