Skip to content

Commit fb35434

Browse files
jaydelucalaurit
andauthored
Kotlin coroutines and ktor metadata (open-telemetry#15295)
Co-authored-by: Lauri Tulmin <[email protected]>
1 parent 9aad1e6 commit fb35434

File tree

11 files changed

+528
-2
lines changed

11 files changed

+528
-2
lines changed

docs/instrumentation-list.yaml

Lines changed: 382 additions & 0 deletions
Large diffs are not rendered by default.

instrumentation-docs/instrumentations.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ readonly INSTRUMENTATIONS=(
150150
"jsp-2.3:javaagent:testExperimental"
151151
"kafka:kafka-clients:kafka-clients-2.6:library:test"
152152
"kafka:kafka-connect-2.6:testing:test"
153+
"ktor:ktor-1.0:library:test"
154+
"ktor:ktor-2.0:library:test"
155+
"ktor:ktor-3.0:library:test"
153156
"kubernetes-client-7.0:javaagent:test"
154157
"kubernetes-client-7.0:javaagent:testExperimental"
155158
"nats:nats-2.17:javaagent:test"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
description: >
2+
This instrumentation enables context propagation for Kotlin coroutines and adds support for
3+
@WithSpan annotations on Kotlin suspend functions.
4+
display_name: Kotlin Coroutines
5+
features:
6+
- CONTEXT_PROPAGATION
7+
library_link: https://github.com/Kotlin/kotlinx.coroutines
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
description: This instrumentation adds support for @WithSpan annotations on methods that return Kotlin Flow.
2+
display_name: Kotlin Coroutines Flow
3+
library_link: https://github.com/Kotlin/kotlinx.coroutines

instrumentation/ktor/ktor-1.0/library/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ kotlin {
3131
}
3232
}
3333

34-
tasks.withType<Test>().configureEach {
35-
jvmArgs("-Dotel.instrumentation.common.experimental.controller-telemetry.enabled=true")
34+
tasks.test {
35+
systemProperty("collectMetadata", findProperty("collectMetadata")?.toString() ?: "false")
3636
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
description: This standalone instrumentation enables HTTP server spans and HTTP server metrics for the Ktor server.
2+
semantic_conventions:
3+
- HTTP_SERVER_SPANS
4+
- HTTP_SERVER_METRICS
5+
features:
6+
- HTTP_ROUTE
7+
library_link: https://ktor.io/

instrumentation/ktor/ktor-2.0/javaagent/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,7 @@ kotlin {
5959
javaParameters = true
6060
}
6161
}
62+
63+
tasks.test {
64+
systemProperty("collectMetadata", findProperty("collectMetadata")?.toString() ?: "false")
65+
}

instrumentation/ktor/ktor-2.0/library/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,7 @@ kotlin {
3737
languageVersion.set(KotlinVersion.KOTLIN_1_8)
3838
}
3939
}
40+
41+
tasks.test {
42+
systemProperty("collectMetadata", findProperty("collectMetadata")?.toString() ?: "false")
43+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
description: >
2+
This instrumentation provides HTTP server spans and HTTP server metrics for the Ktor server,
3+
and HTTP client spans and HTTP client metrics for the Ktor HTTP client.
4+
semantic_conventions:
5+
- HTTP_SERVER_SPANS
6+
- HTTP_SERVER_METRICS
7+
- HTTP_CLIENT_SPANS
8+
- HTTP_CLIENT_METRICS
9+
features:
10+
- HTTP_ROUTE
11+
library_link: https://ktor.io/
12+
configurations:
13+
- name: otel.instrumentation.http.known-methods
14+
description: >
15+
Configures the instrumentation to recognize an alternative set of HTTP request methods. All
16+
other methods will be treated as `_OTHER`.
17+
type: list
18+
default: "CONNECT,DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT,TRACE"
19+
- name: otel.instrumentation.http.server.capture-request-headers
20+
description: List of HTTP request headers to capture in HTTP server telemetry.
21+
type: list
22+
default: ""
23+
- name: otel.instrumentation.http.server.capture-response-headers
24+
description: List of HTTP response headers to capture in HTTP server telemetry.
25+
type: list
26+
default: ""
27+
- name: otel.instrumentation.http.server.emit-experimental-telemetry
28+
description: >
29+
Enable the capture of experimental HTTP server telemetry. Adds the `http.request.body.size`
30+
and `http.response.body.size` attributes to spans, and records `http.server.request.size` and
31+
`http.server.response.size` metrics.
32+
type: boolean
33+
default: false
34+
- name: otel.instrumentation.http.client.capture-request-headers
35+
description: List of HTTP request headers to capture in HTTP client telemetry.
36+
type: list
37+
default: ""
38+
- name: otel.instrumentation.http.client.capture-response-headers
39+
description: List of HTTP response headers to capture in HTTP client telemetry.
40+
type: list
41+
default: ""
42+
- name: otel.instrumentation.common.peer-service-mapping
43+
description: Used to specify a mapping from host names or IP addresses to peer services.
44+
type: map
45+
default: ""
46+
- name: otel.instrumentation.http.client.emit-experimental-telemetry
47+
description: >
48+
Enable the capture of experimental HTTP client telemetry. Adds the `http.request.body.size`
49+
and `http.response.body.size` attributes to spans, and records `http.client.request.size` and
50+
`http.client.response.size` metrics.
51+
type: boolean
52+
default: false
53+
- name: otel.instrumentation.http.client.experimental.redact-query-parameters
54+
description: Redact sensitive URL parameters. See https://opentelemetry.io/docs/specs/semconv/http/http-spans.
55+
type: boolean
56+
default: true

instrumentation/ktor/ktor-3.0/library/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,7 @@ kotlin {
3232
languageVersion.set(KotlinVersion.KOTLIN_1_8)
3333
}
3434
}
35+
36+
tasks.test {
37+
systemProperty("collectMetadata", findProperty("collectMetadata")?.toString() ?: "false")
38+
}

0 commit comments

Comments
 (0)