You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
KG-217. Add a span adapter for the Open Telemetry feature
- Span adapter provides an ability to customize the span behavior for the Open Telemetry that can be used by a specific provider which expects a specific span structure.
Copy file name to clipboardExpand all lines: agents/agents-features/agents-features-opentelemetry/src/jvmMain/kotlin/ai/koog/agents/features/opentelemetry/feature/OpenTelemetry.kt
+57-30Lines changed: 57 additions & 30 deletions
Original file line number
Diff line number
Diff line change
@@ -64,6 +64,7 @@ public class OpenTelemetry {
64
64
val interceptContext =InterceptContext(this, OpenTelemetry())
65
65
val tracer = config.tracer
66
66
val spanProcessor =SpanProcessor(tracer)
67
+
val spanAdapter = config.spanAdapter
67
68
68
69
// Stop all unfinished spans on a process finish to report them
69
70
Runtime.getRuntime().addShutdownHook(
@@ -106,6 +107,7 @@ public class OpenTelemetry {
106
107
strategyName = eventContext.strategy.name
107
108
)
108
109
110
+
spanAdapter?.onBeforeSpanStarted(invokeAgentSpan)
109
111
spanProcessor.startSpan(invokeAgentSpan)
110
112
}
111
113
@@ -123,7 +125,10 @@ public class OpenTelemetry {
123
125
agentId = eventContext.agentId,
124
126
runId = eventContext.runId
125
127
)
126
-
spanProcessor.endSpan(spanId = invokeAgentSpanId)
128
+
129
+
val invokeAgentSpan = spanProcessor.getSpanOrThrow<InvokeAgentSpan>(invokeAgentSpanId)
Copy file name to clipboardExpand all lines: agents/agents-features/agents-features-opentelemetry/src/jvmMain/kotlin/ai/koog/agents/features/opentelemetry/feature/OpenTelemetryConfig.kt
Copy file name to clipboardExpand all lines: agents/agents-features/agents-features-opentelemetry/src/jvmMain/kotlin/ai/koog/agents/features/opentelemetry/integrations/Langfuse.kt
+3-1Lines changed: 3 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@ public fun OpenTelemetryConfig.addLangfuseExporter(
26
26
langfuseSecretKey:String? = null,
27
27
timeout:Duration = 10.seconds,
28
28
) {
29
-
val url = langfuseUrl ?:System.getenv()["LANGFUSE_URL"] ?:"https://cloud.langfuse.com"
29
+
val url = langfuseUrl ?:System.getenv()["LANGFUSE_HOST"] ?:"https://cloud.langfuse.com"
30
30
31
31
logger.debug { "Configured endpoint for Langfuse telemetry: $url" }
32
32
@@ -45,6 +45,8 @@ public fun OpenTelemetryConfig.addLangfuseExporter(
Copy file name to clipboardExpand all lines: agents/agents-features/agents-features-opentelemetry/src/jvmMain/kotlin/ai/koog/agents/features/opentelemetry/integrations/Weave.kt
+3-1Lines changed: 3 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -45,6 +45,8 @@ public fun OpenTelemetryConfig.addWeaveExporter(
0 commit comments