-
Notifications
You must be signed in to change notification settings - Fork 837
Description
Which component is this feature for?
Langchain Instrumentation
π Feature description
Emit events to capture chain level and tool call input&output.
π€ Why is this feature needed ?
Currently, the OpenLLMetry LangChain instrumentation captures spans for chain and tool executions, including metadata such as input/output and timing information. However, it does not emit events for the input/output corresponding to key lifecycle points such as:
-
Chain start
-
Chain end
-
Tool start
-
Tool end
I noticed that we did add input/output as span attributes, but this logic should also emit them as events when should_emit_events return true? refer to: https://github.com/traceloop/openllmetry/blob/main/packages/opentelemetry-instrumentation-langchain/opentelemetry/instrumentation/langchain/callback_handler.py#L420
βοΈ How do you aim to achieve this?
When should_emit_events return true and should_send_prompts returns true, we emit input/output as events.
For example
if should_emit_events() and should_send_prompts():
emit_event(
ToolEndEvent(
message=json.dumps(
{"outputs": outputs, "kwargs": kwargs},
cls=CallbackFilteredJSONEncoder,
),
)
ποΈ Additional Information
It looks like the OpenTelemetry GenAI semantic conventions donβt currently define events for chain or tool lifecycle stages. Should OpenLLMetry aim to strictly follow the spec, or would it make sense to introduce a few practical extensions like this?
π Have you spent some time to check if this feature request has been raised before?
- I checked and didn't find similar issue
Are you willing to submit PR?
Yes I am willing to submit a PR!