> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fiddler.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# FiddlerInstrumentationHook

> Centralized instrumentation hook for Strands agents with Fiddler integration.

Centralized instrumentation hook for Strands agents with Fiddler integration.

This hook provider automatically captures telemetry data from Strands agents
and enriches OpenTelemetry spans with Fiddler-specific attributes. It handles
three key events: before invocation, after tool execution, and after model calls.

The hook is automatically injected when using StrandsAgentInstrumentor, so
users typically don't need to manually add it to their agents.

## Example

```python theme={null}
from strands import Agent
from fiddler_strandsagents import FiddlerInstrumentationHook

# Manual usage (not needed with StrandsAgentInstrumentor)
agent = Agent(
    model=model,
    system_prompt="...",
    hooks=[FiddlerInstrumentationHook()]
)
```

## register\_hooks()

Register hook callbacks with the Strands agent registry.

This method is called by the Strands framework to register callbacks
for various agent lifecycle events.

### Parameters

<ParamField path="registry" type="HookRegistry" required={true}>
  The HookRegistry to register callbacks with
</ParamField>

## tool\_end()

Handle the completion of a tool invocation.

Enriches the current OpenTelemetry span with:

* Custom attributes set via set\_span\_attributes() (prefixed 'fiddler.span.user.')
* gen\_ai.tool.input  — JSON-serialised input arguments passed to the tool
* gen\_ai.tool.output — Text extracted from the tool result content

### Parameters

<ParamField path="event" type="AfterToolCallEvent" required={true}>
  AfterToolCallEvent (or legacy AfterToolInvocationEvent) containing
  tool execution details
</ParamField>

## model\_end()

Handle the completion of a model invocation.

Enriches the current OpenTelemetry span with:

* gen\_ai.llm.context  — retrieved context set via set\_llm\_context()
* Custom attributes set via set\_span\_attributes() (prefixed 'fiddler.span.user.')
* gen\_ai.llm.output   — text extracted from the model's response message

### Parameters

<ParamField path="event" type="AfterModelCallEvent" required={true}>
  AfterModelCallEvent (or legacy AfterModelInvocationEvent) containing
  model execution details
</ParamField>

## before\_invocation()

Handle the start of an agent invocation.

Enriches the current OpenTelemetry span with:

* Conversation ID set via set\_conversation\_id()
* Session attributes set via set\_session\_attributes()
* gen\_ai.llm.input.user — text of the last user message in the invocation

Session attributes and conversation ID are also written to
`event.agent.trace_attributes` so that Strands (>=1.19.0) propagates
them natively to all child spans (model invoke, tool call, event-loop
cycle, etc.) without needing manual parent-to-child denormalisation in
a SpanProcessor.

### Parameters

<ParamField path="event" type="BeforeInvocationEvent" required={true}>
  BeforeInvocationEvent containing agent invocation details
</ParamField>
