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
- Convert event field to a single attribute;
- Fix service name and service version;
- Update tests;
- Update README.md according to xthe latest changes.
|`setServiceInfo`|`serviceName: String, serviceVersion: String, serviceNamespace: String?`| Sets the service information including name, version and optional namespace.|
81
-
|`addSpanExporter`|`exporter: SpanExporter`| Adds a span exporter to send telemetry data to external systems. |
82
-
|`addSpanProcessor`|`processor: SpanProcessor`| Adds a span processor to process spans before they are exported.|
83
-
|`addResourceAttributes`|`attributes: Map<String, String>`| Adds resource attributes to provide additional context about the service. |
84
-
|`setSampler`|`sampler: Sampler`| Sets the sampling strategy to control which spans are collected. |
85
-
|`setVerbose`|`verbose: Boolean`| Enables or disables verbose logging for debugging OpenTelemetry configuration. |
|`setServiceInfo`|`serviceName: String, serviceVersion: String`| Sets the service information including name and version. |
80
+
|`addSpanExporter`|`exporter: SpanExporter`| Adds a span exporter to send telemetry data to external systems.|
81
+
|`addSpanProcessor`|`processor: (SpanExporter) -> SpanProcessor`| Adds a span processor creator function to process spans before they are exported. |
82
+
|`addResourceAttributes`|`attributes: Map<AttributeKey<T>, T> where T : Any`| Adds resource attributes to provide additional context about the service.|
83
+
|`setSampler`|`sampler: Sampler`| Sets the sampling strategy to control which spans are collected.|
84
+
|`setVerbose`|`verbose: Boolean`| Enables or disables verbose logging for debugging OpenTelemetry configuration.|
86
85
87
86
88
87
### Advanced configuration
@@ -99,9 +98,9 @@ install(OpenTelemetry) {
99
98
100
99
// Add resource attributes
101
100
addResourceAttributes(mapOf(
102
-
AttributeKey.stringKey(OpenTelemetryConfig.DEPLOYMENT_ENVIRONMENT to "production"),
103
-
AttributeKey.stringKey("custom.attribute") to "custom-value")
104
-
)
101
+
AttributeKey.stringKey("deployment.environment") to "production",
102
+
AttributeKey.stringKey("custom.attribute") to "custom-value"
103
+
))
105
104
}
106
105
```
107
106
@@ -115,49 +114,78 @@ to use. The available method is:
115
114
#### Resource attributes
116
115
117
116
Resource attributes represent additional information about a process producing telemetry. This information can be
118
-
included in an OpenTelemetry configuration in Koog using the `addResourceAttribute()` method that takes a key and
119
-
a string value as its arguments. Standard resource attribute keys are provided as constants such as `OpenTelemetryConfig.DEPLOYMENT_ENVIRONMENT` and are as follows:
117
+
included in an OpenTelemetry configuration in Koog using the `addResourceAttributes()` method that takes a map of
118
+
`AttributeKey<T>` to values of type `T`.
119
+
120
+
The following default resource attributes are automatically added:
121
+
122
+
-`service.name`: The name of the service being instrumented. Set to the value of `serviceName`.
123
+
-`service.version`: The version of the service being instrumented. Set to the value of `serviceVersion`.
124
+
-`service.instance.time`: The timestamp when the service instance was created.
125
+
-`os.type`: The operating system type.
126
+
-`os.version`: The operating system version.
127
+
-`os.arch`: The operating system architecture.
128
+
129
+
The OpenTelemetry feature automatically adds various attributes to spans following the [OpenTelemetry Semantic Convention for GenAI](https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-spans/):
130
+
131
+
### Common Attributes
132
+
133
+
-`gen_ai.operation.name`: the type of operation being performed (e.g., "create_agent", "invoke_agent", "chat", "execute_tool")
134
+
-`gen_ai.system`: the LLM provider being used
135
+
-`gen_ai.agent.id`: the ID of the agent
136
+
-`gen_ai.agent.name`: the name of the agent (when available)
137
+
-`gen_ai.conversation.id`: the ID of the conversation/run
138
+
-`gen_ai.request.model`: the LLM model being used
139
+
-`gen_ai.request.temperature`: the temperature parameter for the LLM request
140
+
-`error.type`: the type of error that occurred (when applicable)
141
+
142
+
### Custom Attributes
143
+
144
+
Some custom attributes specific to Koog are also added:
145
+
146
+
-`koog.agent.strategy.name`: the name of the agent strategy
147
+
-`koog.node.name`: the name of the node being executed
148
+
149
+
### Span Types
120
150
121
-
-`SERVICE_NAME`: The name of the service being instrumented. Automatically inferred from the `serviceName` property, if set.
122
-
-`SERVICE_VERSION`: The version of the service being instrumented. Automatically inferred from the `serviceVersion` property, if set.
123
-
-`DEPLOYMENT_ENVIRONMENT`: The label for the deployment environment where the process is running. For example, `production`.
151
+
The OpenTelemetry feature creates different types of spans for various operations:
124
152
125
-
The OpenTelemetry feature automatically adds various attributes to spans:
153
+
1.**Create Agent Span**: Represents the creation of an agent
Exporters send collected telemetry data to an OpenTelemetry Collector or other types of destinations or backend implementations.
139
171
140
-
### OTLP Exporter
172
+
### OTLP Exporter example
141
173
142
174
The OTLP (OpenTelemetry Protocol) exporter sends telemetry data to an OpenTelemetry Collector. This is useful for integrating with systems like Jaeger, Zipkin, or Prometheus.
143
175
144
-
To add an OpenTelemetry Exporter, use the `addOtlpExporter` function. The function takes a single argument:
145
-
146
-
| Name | Data type | Required | Default | Description |
Copy file name to clipboardExpand all lines: agents/agents-features/agents-features-opentelemetry/src/jvmMain/kotlin/ai/koog/agents/features/opentelemetry/attribute/attributes.kt
Copy file name to clipboardExpand all lines: agents/agents-features/agents-features-opentelemetry/src/jvmMain/kotlin/ai/koog/agents/features/opentelemetry/event/AssistantMessageEvent.kt
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -28,11 +28,11 @@ internal data class AssistantMessageEvent(
Copy file name to clipboardExpand all lines: agents/agents-features/agents-features-opentelemetry/src/jvmMain/kotlin/ai/koog/agents/features/opentelemetry/event/ChoiceEvent.kt
0 commit comments