Skip to content

Commit 1681d50

Browse files
committed
more modules and print description checklist
1 parent 9b72101 commit 1681d50

File tree

7 files changed

+96
-5
lines changed

7 files changed

+96
-5
lines changed

docs/instrumentation-list.yaml

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,8 @@ libraries:
470470
- name: url.full
471471
type: STRING
472472
- name: apache-httpclient-4.0
473-
description: This instrumentation provides CLIENT spans and metrics for versions
474-
2 and 3 of the Apache HttpClient.
473+
description: This instrumentation provides CLIENT spans and metrics for version
474+
4 of the Apache HttpClient.
475475
source_path: instrumentation/apache-httpclient/apache-httpclient-4.0
476476
scope:
477477
name: io.opentelemetry.apache-httpclient-4.0
@@ -517,12 +517,53 @@ libraries:
517517
- name: url.full
518518
type: STRING
519519
- name: apache-httpclient-4.3
520+
description: This instrumentation provides a library integration that enables
521+
CLIENT spans and metrics for the Apache HttpClient.
520522
source_path: instrumentation/apache-httpclient/apache-httpclient-4.3
521523
scope:
522524
name: io.opentelemetry.apache-httpclient-4.3
523525
target_versions:
524526
library:
525527
- 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
526567
- name: apache-httpclient-5.0
527568
source_path: instrumentation/apache-httpclient/apache-httpclient-5.0
528569
scope:
@@ -3000,6 +3041,8 @@ libraries:
30003041
- jakarta.servlet:jakarta.servlet-api:[5.0.0,)
30013042
spark:
30023043
- 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.
30033046
source_path: instrumentation/spark-2.3
30043047
scope:
30053048
name: io.opentelemetry.spark-2.3

instrumentation-docs/collect.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ readonly INSTRUMENTATIONS=(
2222
# "apache-dbcp-2.0:javaagent:test"
2323
# "apache-dbcp-2.0:javaagent:testStableSemconv"
2424
# "apache-httpclient:apache-httpclient-2.0:javaagent:test"
25-
"apache-httpclient:apache-httpclient-4.0:javaagent:test"
25+
# "apache-httpclient:apache-httpclient-4.0:javaagent:test"
26+
"apache-httpclient:apache-httpclient-4.3:library:test"
2627
# "apache-httpclient:apache-httpclient-5.0:javaagent:test"
2728
# "apache-dubbo-2.7:javaagent:testDubbo"
2829
# "c3p0-0.9:javaagent:test"

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

Lines changed: 21 additions & 1 deletion
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;
@@ -82,6 +83,8 @@ private static void printStats(List<InstrumentationModule> modules) {
8283
getPercentage("configurations", withConfigurations, modules.size()));
8384

8485
logger.info(stats);
86+
87+
logger.info(modulesWithDescriptions(modules));
8588
}
8689

8790
private static String getClassificationStats(List<InstrumentationModule> modules) {
@@ -108,7 +111,7 @@ private static String getPercentage(String label, long numerator, long denominat
108111
}
109112

110113
@SuppressWarnings("unused") // helper method used for project tracking
111-
private static String listModules(List<InstrumentationModule> modules) {
114+
private static String listAllModules(List<InstrumentationModule> modules) {
112115
// Create a checklist of all modules sorted by name
113116
return modules.stream()
114117
.map(InstrumentationModule::getInstrumentationName)
@@ -117,5 +120,22 @@ private static String listModules(List<InstrumentationModule> modules) {
117120
.collect(Collectors.joining("\n"));
118121
}
119122

123+
@SuppressWarnings("unused") // helper method used for project tracking
124+
private static String modulesWithDescriptions(List<InstrumentationModule> modules) {
125+
// Create a checklist of all modules sorted by name, checked if description is set
126+
return modules.stream()
127+
.sorted(Comparator.comparing(InstrumentationModule::getInstrumentationName))
128+
.map(
129+
module -> {
130+
boolean hasDescription =
131+
module.getMetadata() != null
132+
&& module.getMetadata().getDescription() != null
133+
&& !module.getMetadata().getDescription().isEmpty();
134+
String checkbox = hasDescription ? "- [x] " : "- [ ] ";
135+
return checkbox + module.getInstrumentationName();
136+
})
137+
.collect(Collectors.joining("\n"));
138+
}
139+
120140
private DocGeneratorApplication() {}
121141
}

instrumentation/apache-httpclient/apache-httpclient-4.3/library/build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,10 @@ dependencies {
1111

1212
latestDepTestLibrary("org.apache.httpcomponents:httpclient:4.+") // see apache-httpclient-5.0 module
1313
}
14+
15+
tasks {
16+
test {
17+
systemProperty("collectMetadata", findProperty("collectMetadata")?.toString() ?: "false")
18+
systemProperty("collectSpans", true)
19+
}
20+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
description: This instrumentation provides a library integration that enables CLIENT spans and metrics for the Apache HttpClient.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
description: >
2+
This instrumentation does not emit telemetry on its own. Instead, it extracts the HTTP route and
3+
attaches it to SERVER spans and HTTP server metrics.

testing-common/src/main/java/io/opentelemetry/instrumentation/testing/LibraryTestRunner.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import io.opentelemetry.context.propagation.TextMapPropagator;
2121
import io.opentelemetry.contrib.baggage.processor.BaggageSpanProcessor;
2222
import io.opentelemetry.exporter.logging.LoggingSpanExporter;
23+
import io.opentelemetry.instrumentation.testing.internal.MetaDataCollector;
2324
import io.opentelemetry.sdk.OpenTelemetrySdk;
2425
import io.opentelemetry.sdk.common.CompletableResultCode;
2526
import io.opentelemetry.sdk.logs.SdkLoggerProvider;
@@ -39,6 +40,9 @@
3940
import io.opentelemetry.sdk.trace.SpanProcessor;
4041
import io.opentelemetry.sdk.trace.data.SpanData;
4142
import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor;
43+
import java.io.IOException;
44+
import java.net.URL;
45+
import java.nio.file.Paths;
4246
import java.time.Duration;
4347
import java.util.List;
4448
import java.util.concurrent.TimeUnit;
@@ -116,7 +120,19 @@ public void beforeTestClass() {
116120
}
117121

118122
@Override
119-
public void afterTestClass() {}
123+
public void afterTestClass() throws IOException {
124+
// Generates files in a `.telemetry` directory within the instrumentation module with all
125+
// captured emitted metadata to be used by the instrumentation-docs Doc generator.
126+
if (Boolean.getBoolean("collectMetadata")) {
127+
URL resource = this.getClass().getClassLoader().getResource("");
128+
if (resource == null) {
129+
return;
130+
}
131+
String path = Paths.get(resource.getPath()).toString();
132+
133+
MetaDataCollector.writeTelemetryToFiles(path, metrics, tracesByScope);
134+
}
135+
}
120136

121137
@Override
122138
public void clearAllExportedData() {

0 commit comments

Comments
 (0)