feat(callbacks): add native OpenTelemetry callback handler - #1270
Open
JopenChen wants to merge 1 commit into
Open
feat(callbacks): add native OpenTelemetry callback handler#1270JopenChen wants to merge 1 commit into
JopenChen wants to merge 1 commit into
Conversation
|
|
Add a new callbacks/otel package that implements the callbacks.Handler interface with OpenTelemetry tracing following the GenAI semantic conventions. This addresses the community request for native OTel support (Issue cloudwego#1028), eliminating the need for users to implement callbacks manually. Features: - Span creation for ChatModel, Tool, Retriever, Embedding, Graph, Chain, Workflow, and other component types - GenAI standard attributes: gen_ai.system, gen_ai.operation.name, gen_ai.request.model, gen_ai.response.model, gen_ai.usage.*, gen_ai.tool.name - Token usage extraction from model.CallbackOutput (input/output/total tokens) - Query and document count attributes for Retriever components - Nested span propagation (child spans automatically link to parent) - Error recording with span status codes - TimingChecker implementation to skip stream callbacks and reduce overhead - Configurable via WithTracerProvider and WithTracer options Usage: callbacks.AppendGlobalHandlers(otel.NewHandler()) // or handler := otel.NewHandler(otel.WithTracerProvider(tp)) Note: This upgrades the minimum Go version to 1.25.0 as required by go.opentelemetry.io/otel v1.46.0. Refs cloudwego#1028
JopenChen
force-pushed
the
feat/otel-callback-handler
branch
from
September 9, 2026 09:09
3e4c38c to
90f03d0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
feat
Check the PR title.
(Optional) Translate the PR title into Chinese.
feat(callbacks): 新增原生 OpenTelemetry callback handler
(Optional) More detailed description for this PR(en: English/zh: Chinese).
en:
Add a new
callbacks/otelpackage that implementscallbacks.Handlerwith OpenTelemetry tracing following the GenAI semantic conventions.Addresses community request #1028 for native OTel support. Currently users must implement callbacks manually to get distributed tracing for LLM applications built with eino.
Features:
Usage:
zh(optional):
新增
callbacks/otel包,实现遵循 GenAI 语义约定的 OpenTelemetry callback handler。响应社区需求 #1028,提供原生 OTel 支持。目前用户必须手动实现 callbacks 才能获得分布式追踪。
特性:
(Optional) Which issue(s) this PR fixes:
Fixes #1028
(optional) The PR that updates user documentation:
Will follow up with a docs PR if this feature is accepted.