feat(agents): support OpenTelemetry metrics#1381
Open
Conversation
egorklimov
reviewed
Jan 21, 2026
sdubov
requested changes
Jan 21, 2026
Collaborator
sdubov
left a comment
There was a problem hiding this comment.
I like the consistency for current metrics support implementation. Thank you. Please check my comments about some metrics implementation details.
...emetry/src/jvmMain/kotlin/ai/koog/agents/features/opentelemetry/attribute/GenAIAttributes.kt
Outdated
Show resolved
Hide resolved
examples/simple-examples/src/main/kotlin/ai/koog/agents/example/calculator/Calculator.kt
Outdated
Show resolved
Hide resolved
...emetry/src/jvmMain/kotlin/ai/koog/agents/features/opentelemetry/attribute/GenAIAttributes.kt
Outdated
Show resolved
Hide resolved
...ntelemetry/src/jvmMain/kotlin/ai/koog/agents/features/opentelemetry/feature/OpenTelemetry.kt
Outdated
Show resolved
Hide resolved
...ntelemetry/src/jvmMain/kotlin/ai/koog/agents/features/opentelemetry/feature/OpenTelemetry.kt
Outdated
Show resolved
Hide resolved
...pentelemetry/src/jvmMain/kotlin/ai/koog/agents/features/opentelemetry/metric/TokenCounter.kt
Outdated
Show resolved
Hide resolved
...telemetry/src/jvmMain/kotlin/ai/koog/agents/features/opentelemetry/metric/ToolCallCounter.kt
Outdated
Show resolved
Hide resolved
...rc/jvmMain/kotlin/ai/koog/agents/features/opentelemetry/metric/OperationDurationHistogram.kt
Outdated
Show resolved
Hide resolved
...elemetry/src/jvmMain/kotlin/ai/koog/agents/features/opentelemetry/metric/GenAIMetricNames.kt
Outdated
Show resolved
Hide resolved
...ntelemetry/src/jvmMain/kotlin/ai/koog/agents/features/opentelemetry/feature/OpenTelemetry.kt
Outdated
Show resolved
Hide resolved
sdubov
reviewed
Jan 22, 2026
...etry/src/jvmMain/kotlin/ai/koog/agents/features/opentelemetry/feature/OpenTelemetryConfig.kt
Outdated
Show resolved
Hide resolved
sdubov
reviewed
Jan 22, 2026
...ntelemetry/src/jvmMain/kotlin/ai/koog/agents/features/opentelemetry/feature/OpenTelemetry.kt
Outdated
Show resolved
Hide resolved
egorklimov
requested changes
Feb 4, 2026
...emetry/src/jvmMain/kotlin/ai/koog/agents/features/opentelemetry/metric/MetricEventStorage.kt
Outdated
Show resolved
Hide resolved
egorklimov
requested changes
Feb 5, 2026
...entelemetry/src/jvmMain/kotlin/ai/koog/agents/features/opentelemetry/metric/MetricObjects.kt
Outdated
Show resolved
Hide resolved
egorklimov
approved these changes
Feb 6, 2026
sdubov
approved these changes
Feb 11, 2026
Collaborator
sdubov
left a comment
There was a problem hiding this comment.
As we discussed, I have two concerns here:
restricToolNameCardinalityconfig which I found a bit confusing. As I noticed, I would implement this as an extension for a metric adapter (similar to the span adapter).- Single responsibility for MetricCollector class. I would prefer it to be able to track any metric and help to create it if needed (keep the timestamp for a start event if needed for now).
Other than that, looks good for me. We can address some of those questions later in a further commits. For now, I will approve this one to not block the development.
...ntelemetry/src/jvmMain/kotlin/ai/koog/agents/features/opentelemetry/metric/KoogMetricName.kt
Outdated
Show resolved
Hide resolved
...telemetry/src/jvmMain/kotlin/ai/koog/agents/features/opentelemetry/metric/KoogMetricNames.kt
Outdated
Show resolved
Hide resolved
...-opentelemetry/src/jvmMain/kotlin/ai/koog/agents/features/opentelemetry/metric/MetricName.kt
Outdated
Show resolved
Hide resolved
...etry/src/jvmMain/kotlin/ai/koog/agents/features/opentelemetry/feature/OpenTelemetryConfig.kt
Outdated
Show resolved
Hide resolved
...telemetry/src/jvmMain/kotlin/ai/koog/agents/features/opentelemetry/metric/GenAIMetricName.kt
Outdated
Show resolved
Hide resolved
...elemetry/src/jvmMain/kotlin/ai/koog/agents/features/opentelemetry/metric/GenAIMetricNames.kt
Outdated
Show resolved
Hide resolved
...elemetry/src/jvmMain/kotlin/ai/koog/agents/features/opentelemetry/metric/GenAIMetricNames.kt
Outdated
Show resolved
Hide resolved
...elemetry/src/jvmMain/kotlin/ai/koog/agents/features/opentelemetry/metric/GenAIMetricNames.kt
Outdated
Show resolved
Hide resolved
90369c1 to
a081034
Compare
egorklimov
requested changes
Feb 13, 2026
...ntelemetry/src/jvmMain/kotlin/ai/koog/agents/features/opentelemetry/feature/OpenTelemetry.kt
Show resolved
Hide resolved
egorklimov
approved these changes
Feb 13, 2026
sdubov
reviewed
Feb 17, 2026
...entelemetry/src/jvmMain/kotlin/ai/koog/agents/features/opentelemetry/attribute/attributes.kt
Outdated
Show resolved
Hide resolved
examples/simple-examples/src/main/kotlin/ai/koog/agents/example/calculator/Calculator.kt
Outdated
Show resolved
Hide resolved
...entelemetry/src/jvmMain/kotlin/ai/koog/agents/features/opentelemetry/attribute/attributes.kt
Outdated
Show resolved
Hide resolved
3c8b58a to
cd1a58d
Compare
04ce47e to
4535497
Compare
egorklimov
requested changes
Feb 17, 2026
49129e2 to
fbba4e9
Compare
bcd52c2 to
7707721
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.
Motivation and Context
PR introduces metrics support based on OpenTelemetry specification. Such metrics allow their listeners observe the behaviour of agent in run-time. All changes are done within OpenTelemetry feature
Link to issue
Added configuration:
addMeterExporter(MetricExporter)-- function within OpenTelemetry feature that accept MetricExporter and sent library metrics via such exporterExample of OpenTelemetry feature configuration:
Added metrics:
Visualisation (via OpenTelemetry plugin):


Breaking Changes
Type of the changes
Checklist
developas the base branchAdditional steps for pull requests adding a new feature