Skip to content

Commit 86f94fc

Browse files
authored
Gather more span metadata (#14105)
1 parent d8723a4 commit 86f94fc

File tree

19 files changed

+322
-17
lines changed

19 files changed

+322
-17
lines changed

docs/instrumentation-list.yaml

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,49 @@ libraries:
1414
target_versions:
1515
javaagent:
1616
- io.activej:activej-http:[6.0,)
17+
telemetry:
18+
- when: default
19+
metrics:
20+
- name: http.server.request.duration
21+
description: Duration of HTTP server requests.
22+
type: HISTOGRAM
23+
unit: s
24+
attributes:
25+
- name: http.request.method
26+
type: STRING
27+
- name: http.response.status_code
28+
type: LONG
29+
- name: network.protocol.version
30+
type: STRING
31+
- name: url.scheme
32+
type: STRING
33+
spans:
34+
- span_kind: SERVER
35+
attributes:
36+
- name: client.address
37+
type: STRING
38+
- name: error.type
39+
type: STRING
40+
- name: http.request.method
41+
type: STRING
42+
- name: http.response.status_code
43+
type: LONG
44+
- name: network.peer.address
45+
type: STRING
46+
- name: network.protocol.version
47+
type: STRING
48+
- name: server.address
49+
type: STRING
50+
- name: server.port
51+
type: LONG
52+
- name: url.path
53+
type: STRING
54+
- name: url.query
55+
type: STRING
56+
- name: url.scheme
57+
type: STRING
58+
- name: user_agent.original
59+
type: STRING
1760
akka:
1861
- name: akka-actor-2.3
1962
source_path: instrumentation/akka/akka-actor-2.3
@@ -214,6 +257,9 @@ libraries:
214257
type: STRING
215258
apache:
216259
- name: apache-dbcp-2.0
260+
description: |
261+
This instrumentation provides database connection pools metrics for Apache DBCP.
262+
The instrumentation uses `MBeanRegistration` methods for lifecycle detection, therefore it only activates if the `BasicDataSource` is registered to an `MBeanServer`. If using Spring Boot, this happens automatically as all Spring beans that support JMX registration are automatically registered by default.
217263
source_path: instrumentation/apache-dbcp-2.0
218264
scope:
219265
name: io.opentelemetry.apache-dbcp-2.0
@@ -334,6 +380,8 @@ libraries:
334380
- name: rpc.system
335381
type: STRING
336382
- name: apache-httpasyncclient-4.1
383+
description: This instrumentation provides CLIENT spans and metrics for the Apache
384+
HttpAsyncClient.
337385
source_path: instrumentation/apache-httpasyncclient-4.1
338386
scope:
339387
name: io.opentelemetry.apache-httpasyncclient-4.1
@@ -358,28 +406,164 @@ libraries:
358406
type: STRING
359407
- name: server.port
360408
type: LONG
409+
spans:
410+
- span_kind: CLIENT
411+
attributes:
412+
- name: error.type
413+
type: STRING
414+
- name: http.request.method
415+
type: STRING
416+
- name: http.request.method_original
417+
type: STRING
418+
- name: http.response.status_code
419+
type: LONG
420+
- name: network.protocol.version
421+
type: STRING
422+
- name: server.address
423+
type: STRING
424+
- name: server.port
425+
type: LONG
426+
- name: url.full
427+
type: STRING
361428
- name: apache-httpclient-2.0
429+
description: This instrumentation provides CLIENT spans and metrics for versions
430+
2 and 3 of the Apache HttpClient.
362431
source_path: instrumentation/apache-httpclient/apache-httpclient-2.0
363432
scope:
364433
name: io.opentelemetry.apache-httpclient-2.0
365434
target_versions:
366435
javaagent:
367436
- commons-httpclient:commons-httpclient:[2.0,4.0)
437+
telemetry:
438+
- when: default
439+
metrics:
440+
- name: http.client.request.duration
441+
description: Duration of HTTP client requests.
442+
type: HISTOGRAM
443+
unit: s
444+
attributes:
445+
- name: http.request.method
446+
type: STRING
447+
- name: http.response.status_code
448+
type: LONG
449+
- name: network.protocol.version
450+
type: STRING
451+
- name: server.address
452+
type: STRING
453+
- name: server.port
454+
type: LONG
455+
spans:
456+
- span_kind: CLIENT
457+
attributes:
458+
- name: error.type
459+
type: STRING
460+
- name: http.request.method
461+
type: STRING
462+
- name: http.response.status_code
463+
type: LONG
464+
- name: network.protocol.version
465+
type: STRING
466+
- name: server.address
467+
type: STRING
468+
- name: server.port
469+
type: LONG
470+
- name: url.full
471+
type: STRING
368472
- name: apache-httpclient-4.0
473+
description: This instrumentation provides CLIENT spans and metrics for version
474+
4 of the Apache HttpClient.
369475
source_path: instrumentation/apache-httpclient/apache-httpclient-4.0
370476
scope:
371477
name: io.opentelemetry.apache-httpclient-4.0
372478
target_versions:
373479
javaagent:
374480
- io.dropwizard:dropwizard-client:(,3.0.0)
375481
- org.apache.httpcomponents:httpclient:[4.0,)
482+
telemetry:
483+
- when: default
484+
metrics:
485+
- name: http.client.request.duration
486+
description: Duration of HTTP client requests.
487+
type: HISTOGRAM
488+
unit: s
489+
attributes:
490+
- name: http.request.method
491+
type: STRING
492+
- name: http.response.status_code
493+
type: LONG
494+
- name: network.protocol.version
495+
type: STRING
496+
- name: server.address
497+
type: STRING
498+
- name: server.port
499+
type: LONG
500+
spans:
501+
- span_kind: CLIENT
502+
attributes:
503+
- name: error.type
504+
type: STRING
505+
- name: http.request.method
506+
type: STRING
507+
- name: http.request.method_original
508+
type: STRING
509+
- name: http.response.status_code
510+
type: LONG
511+
- name: network.protocol.version
512+
type: STRING
513+
- name: server.address
514+
type: STRING
515+
- name: server.port
516+
type: LONG
517+
- name: url.full
518+
type: STRING
376519
- name: apache-httpclient-4.3
520+
description: This instrumentation provides a library integration that enables
521+
CLIENT spans and metrics for the Apache HttpClient.
377522
source_path: instrumentation/apache-httpclient/apache-httpclient-4.3
378523
scope:
379524
name: io.opentelemetry.apache-httpclient-4.3
380525
target_versions:
381526
library:
382527
- org.apache.httpcomponents:httpclient:[4.3,4.+)
528+
telemetry:
529+
- when: default
530+
metrics:
531+
- name: http.client.request.duration
532+
description: Duration of HTTP client requests.
533+
type: HISTOGRAM
534+
unit: s
535+
attributes:
536+
- name: http.request.method
537+
type: STRING
538+
- name: http.response.status_code
539+
type: LONG
540+
- name: network.protocol.version
541+
type: STRING
542+
- name: server.address
543+
type: STRING
544+
- name: server.port
545+
type: LONG
546+
spans:
547+
- span_kind: CLIENT
548+
attributes:
549+
- name: error.type
550+
type: STRING
551+
- name: http.request.method
552+
type: STRING
553+
- name: http.request.method_original
554+
type: STRING
555+
- name: http.request.resend_count
556+
type: LONG
557+
- name: http.response.status_code
558+
type: LONG
559+
- name: network.protocol.version
560+
type: STRING
561+
- name: server.address
562+
type: STRING
563+
- name: server.port
564+
type: LONG
565+
- name: url.full
566+
type: STRING
383567
- name: apache-httpclient-5.0
384568
source_path: instrumentation/apache-httpclient/apache-httpclient-5.0
385569
scope:
@@ -2857,6 +3041,8 @@ libraries:
28573041
- jakarta.servlet:jakarta.servlet-api:[5.0.0,)
28583042
spark:
28593043
- name: spark-2.3
3044+
description: |
3045+
This instrumentation does not emit telemetry on its own. Instead, it extracts the HTTP route and attaches it to SERVER spans and HTTP server metrics.
28603046
source_path: instrumentation/spark-2.3
28613047
scope:
28623048
name: io.opentelemetry.spark-2.3

instrumentation-docs/collect.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,16 @@ fi
1414

1515
readonly INSTRUMENTATIONS=(
1616
# <module path (colon-separated)> : <javaagent|library> : [ gradle-task-suffix ]
17+
"activej-http-6.0:javaagent:test"
1718
"akka:akka-http-10.0:javaagent:test"
1819
"apache-httpasyncclient-4.1:javaagent:test"
1920
"alibaba-druid-1.0:javaagent:test"
2021
"alibaba-druid-1.0:javaagent:testStableSemconv"
2122
"apache-dbcp-2.0:javaagent:test"
2223
"apache-dbcp-2.0:javaagent:testStableSemconv"
24+
"apache-httpclient:apache-httpclient-2.0:javaagent:test"
25+
"apache-httpclient:apache-httpclient-4.0:javaagent:test"
26+
"apache-httpclient:apache-httpclient-4.3:library:test"
2327
"apache-httpclient:apache-httpclient-5.0:javaagent:test"
2428
"apache-dubbo-2.7:javaagent:testDubbo"
2529
"c3p0-0.9:javaagent:test"
@@ -170,7 +174,7 @@ echo
170174

171175
./gradlew "${gradle_tasks[@]}" \
172176
-PcollectMetadata=true \
173-
--rerun-tasks
177+
--rerun-tasks --continue
174178

175179
# uncomment the next line to remove all .telemetry directories
176180
#find_and_remove_all_telemetry

instrumentation-docs/readme.md

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ Run the analysis to update the instrumentation-list.yaml:
88

99
`./gradlew :instrumentation-docs:runAnalysis`
1010

11-
### Metric collection
11+
### Telemetry collection
1212

1313
Until this process is ready for all instrumentations, each module will be modified to include a
14-
system property feature flag configured for when the tests run:
14+
system property feature flag configured for when the tests run. By enabling the following flag you
15+
will enable metric collection:
1516

1617
```kotlin
1718
tasks {
@@ -22,6 +23,17 @@ tasks {
2223
}
2324
```
2425

26+
In order to collect spans, add the `collectSpans` property (along with `collectMetadata`):
27+
28+
```kotlin
29+
tasks {
30+
test {
31+
systemProperty("collectMetadata", collectMetadata)
32+
systemProperty("collectSpans", true)
33+
}
34+
}
35+
```
36+
2537
Sometimes instrumentation will behave differently based on configuration options, and we can
2638
differentiate between these configurations by using the `metaDataConfig` system property. When the
2739
telemetry is written to a file, the value of this property will be included, or it will default to
@@ -130,6 +142,9 @@ public class SpringWebInstrumentationModule extends InstrumentationModule
130142
* metrics
131143
* List of metrics that the instrumentation module collects, including the metric name, description, type, and attributes.
132144
* Separate lists for the metrics emitted by default vs via configuration options.
145+
* spans
146+
* List of spans kinds the instrumentation module generates, including the attributes and their types.
147+
* Separate lists for the spans emitted by default vs via configuration options.
133148

134149
## Methodology
135150

@@ -168,16 +183,16 @@ name is determined by the instrumentation module name: `io.opentelemetry.{instr
168183
We will implement gatherers for the schemaUrl and scope attributes when instrumentations start
169184
implementing them.
170185

171-
### Metrics
186+
### Spans and Metrics
172187

173-
In order to identify what metrics are emitted from instrumentations, we can hook into the
174-
`InstrumentationTestRunner` class and collect the metrics generated during runs. We can then
188+
In order to identify what telemetry is emitted from instrumentations, we can hook into the
189+
`InstrumentationTestRunner` class and collect the metrics and spans generated during runs. We can then
175190
leverage the `afterTestClass()` in the Agent and library test runners to then write this information
176191
into temporary files. When we analyze the instrumentation modules, we can read these files and
177-
generate the metrics section of the instrumentation-list.yaml file.
192+
generate the telemetry section of the instrumentation-list.yaml file.
178193

179194
The data is written into a `.telemetry` directory in the root of each instrumentation module. This
180195
data will be excluded from git and just generated on demand.
181196

182-
Each file has a `when` value along with the list of metrics that indicates whether the telemetry is emitted by default or via a
183-
configuration option.
197+
Each file has a `when` value along with the list of metrics that indicates whether the telemetry is
198+
emitted by default or via a configuration option.

instrumentation-docs/src/main/java/io/opentelemetry/instrumentation/docs/DocGeneratorApplication.java

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.io.IOException;
1515
import java.nio.file.Files;
1616
import java.nio.file.Paths;
17+
import java.util.Comparator;
1718
import java.util.List;
1819
import java.util.Locale;
1920
import java.util.TreeMap;
@@ -107,5 +108,48 @@ private static String getPercentage(String label, long numerator, long denominat
107108
+ "%)";
108109
}
109110

111+
@SuppressWarnings("unused") // temporary helper method used for project tracking
112+
private static String listAllModules(List<InstrumentationModule> modules) {
113+
return modules.stream()
114+
.map(InstrumentationModule::getInstrumentationName)
115+
.sorted()
116+
.map(name -> "- [ ] " + name)
117+
.collect(Collectors.joining("\n"));
118+
}
119+
120+
@SuppressWarnings("unused") // temporary helper method used for project tracking
121+
private static String modulesWithDescriptions(List<InstrumentationModule> modules) {
122+
// checklist of all modules sorted by name, with a check if description is set
123+
return modules.stream()
124+
.sorted(Comparator.comparing(InstrumentationModule::getInstrumentationName))
125+
.map(
126+
module -> {
127+
boolean hasDescription =
128+
module.getMetadata() != null
129+
&& module.getMetadata().getDescription() != null
130+
&& !module.getMetadata().getDescription().isEmpty();
131+
String checkbox = hasDescription ? "- [x] " : "- [ ] ";
132+
return checkbox + module.getInstrumentationName();
133+
})
134+
.collect(Collectors.joining("\n"));
135+
}
136+
137+
@SuppressWarnings("unused") // temporary helper method used for project tracking
138+
private static String modulesWithConfigs(List<InstrumentationModule> modules) {
139+
// checklist of all modules sorted by name, with a check if config is set
140+
return modules.stream()
141+
.sorted(Comparator.comparing(InstrumentationModule::getInstrumentationName))
142+
.map(
143+
module -> {
144+
boolean hasDescription =
145+
module.getMetadata() != null
146+
&& module.getMetadata().getConfigurations() != null
147+
&& !module.getMetadata().getConfigurations().isEmpty();
148+
String checkbox = hasDescription ? "- [x] " : "- [ ] ";
149+
return checkbox + module.getInstrumentationName();
150+
})
151+
.collect(Collectors.joining("\n"));
152+
}
153+
110154
private DocGeneratorApplication() {}
111155
}

0 commit comments

Comments
 (0)