Skip to content

Commit d757dd8

Browse files
authored
Metadata for influxdb, java server and client, jul, and javalin (#15166)
1 parent d23c493 commit d757dd8

File tree

11 files changed

+97
-12
lines changed

11 files changed

+97
-12
lines changed

docs/contributing/documenting-instrumentation.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ List of possible options:
209209
* `AUTO_INSTRUMENTATION_SHIM`: Instrumentation that adapts or bridges instrumentation from upstream libraries or frameworks
210210
* `CONTROLLER_SPANS`: Instrumentation that generates controller-level spans for controller/handler methods in web frameworks (disabled by default, experimental)
211211
* `VIEW_SPANS`: Instrumentation that generates view-level spans for view rendering such as templates or JSP (disabled by default, experimental)
212+
* `LOGGING_BRIDGE`: Instrumentation that bridges logging framework events to the OpenTelemetry Logs API. These instrumentations capture log records from standard logging frameworks and emit them as OpenTelemetry log records.
212213

213214
### Library Link
214215

docs/instrumentation-list.yaml

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5044,6 +5044,11 @@ libraries:
50445044
target_versions:
50455045
javaagent:
50465046
- org.influxdb:influxdb-java:[2.4,)
5047+
configurations:
5048+
- name: otel.instrumentation.common.db-statement-sanitizer.enabled
5049+
description: Enables or disables statement sanitization for database queries.
5050+
type: boolean
5051+
default: true
50475052
telemetry:
50485053
- when: default
50495054
spans:
@@ -5097,6 +5102,9 @@ libraries:
50975102
- name: java-http-client
50985103
description: This instrumentation enables HTTP client spans and HTTP client metrics
50995104
for requests made using the Java HTTP client.
5105+
semantic_conventions:
5106+
- HTTP_CLIENT_SPANS
5107+
- HTTP_CLIENT_METRICS
51005108
library_link: https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/package-summary.html
51015109
source_path: instrumentation/java-http-client
51025110
minimum_java_version: 11
@@ -5175,6 +5183,9 @@ libraries:
51755183
- name: java-http-server
51765184
description: This instrumentation enables HTTP server spans and HTTP server metrics
51775185
for the Java HTTP server.
5186+
semantic_conventions:
5187+
- HTTP_SERVER_SPANS
5188+
- HTTP_SERVER_METRICS
51785189
library_link: https://docs.oracle.com/en/java/javase/21/docs/api/jdk.httpserver/module-summary.html
51795190
source_path: instrumentation/java-http-server
51805191
scope:
@@ -5255,11 +5266,29 @@ libraries:
52555266
type: STRING
52565267
- name: user_agent.original
52575268
type: STRING
5269+
- name: java-util-logging
5270+
display_name: Java Util Logging (JUL)
5271+
description: This instrumentation bridges Java Util Logging (JUL) log records
5272+
to OpenTelemetry logs.
5273+
library_link: https://docs.oracle.com/en/java/javase/11/docs/api/java.logging/java/util/logging/package-summary.html
5274+
features:
5275+
- LOGGING_BRIDGE
5276+
source_path: instrumentation/java-util-logging
5277+
scope:
5278+
name: io.opentelemetry.java-util-logging
5279+
configurations:
5280+
- name: otel.instrumentation.java-util-logging.experimental-log-attributes
5281+
description: Enables capturing the experimental `thread.name` and `thread.id`
5282+
log attributes.
5283+
type: boolean
5284+
default: false
52585285
javalin:
52595286
- name: javalin-5.0
52605287
description: This instrumentation enriches existing HTTP server spans with route
52615288
information, it does not emit any telemetry on its own.
52625289
library_link: https://javalin.io/
5290+
features:
5291+
- HTTP_ROUTE
52635292
source_path: instrumentation/javalin-5.0
52645293
minimum_java_version: 11
52655294
scope:
@@ -9257,10 +9286,6 @@ internal:
92579286
source_path: instrumentation/internal/internal-class-loader
92589287
scope:
92599288
name: io.opentelemetry.internal-class-loader
9260-
- name: java-util-logging
9261-
source_path: instrumentation/java-util-logging
9262-
scope:
9263-
name: io.opentelemetry.java-util-logging
92649289
- name: internal-reflection
92659290
source_path: instrumentation/internal/internal-reflection
92669291
scope:

instrumentation-docs/readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ public class SpringWebInstrumentationModule extends InstrumentationModule
142142
* AUTO_INSTRUMENTATION_SHIM
143143
* CONTROLLER_SPANS
144144
* VIEW_SPANS
145+
* LOGGING_BRIDGE
145146
* library_link
146147
* URL to the library or framework's main website or documentation, or if those don't exist, the
147148
GitHub repository.

instrumentation-docs/src/main/java/io/opentelemetry/instrumentation/docs/internal/InstrumentationFeature.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ public enum InstrumentationFeature {
1515
AUTO_INSTRUMENTATION_SHIM,
1616
CONTROLLER_SPANS,
1717
VIEW_SPANS,
18+
LOGGING_BRIDGE
1819
}

instrumentation/influxdb-2.4/metadata.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@ semantic_conventions:
44
- DATABASE_CLIENT_SPANS
55
- DATABASE_CLIENT_METRICS
66
library_link: https://github.com/influxdata/influxdb-java
7+
configurations:
8+
- name: otel.instrumentation.common.db-statement-sanitizer.enabled
9+
description: Enables or disables statement sanitization for database queries.
10+
type: boolean
11+
default: true

instrumentation/java-http-client/metadata.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
description: This instrumentation enables HTTP client spans and HTTP client metrics for requests made using the Java HTTP client.
2+
semantic_conventions:
3+
- HTTP_CLIENT_SPANS
4+
- HTTP_CLIENT_METRICS
25
library_link: https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/package-summary.html
36
configurations:
47
- name: otel.instrumentation.http.known-methods

instrumentation/java-http-server/metadata.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
description: This instrumentation enables HTTP server spans and HTTP server metrics for the Java HTTP server.
2+
semantic_conventions:
3+
- HTTP_SERVER_SPANS
4+
- HTTP_SERVER_METRICS
25
library_link: https://docs.oracle.com/en/java/javase/21/docs/api/jdk.httpserver/module-summary.html
36
configurations:
47
- name: otel.instrumentation.http.known-methods

instrumentation/java-util-logging/javaagent/build.gradle.kts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@ dependencies {
1313
testImplementation("org.awaitility:awaitility")
1414
}
1515

16-
tasks.withType<Test>().configureEach {
17-
// TODO run tests both with and without experimental log attributes
18-
jvmArgs("-Dotel.instrumentation.java-util-logging.experimental-log-attributes=true")
16+
tasks {
17+
val testExperimental by registering(Test::class) {
18+
testClassesDirs = sourceSets.test.get().output.classesDirs
19+
classpath = sourceSets.test.get().runtimeClasspath
20+
21+
jvmArgs("-Dotel.instrumentation.java-util-logging.experimental-log-attributes=true")
22+
}
23+
24+
check {
25+
dependsOn(testExperimental)
26+
}
1927
}

instrumentation/java-util-logging/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/jul/JavaUtilLoggingTest.java

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
1919
import io.opentelemetry.sdk.logs.data.LogRecordData;
2020
import io.opentelemetry.semconv.incubating.ThreadIncubatingAttributes;
21+
import io.opentelemetry.testing.internal.armeria.common.annotation.Nullable;
2122
import java.util.logging.Level;
2223
import java.util.logging.Logger;
2324
import java.util.stream.Stream;
@@ -27,6 +28,8 @@
2728
import org.junit.jupiter.params.provider.MethodSource;
2829

2930
class JavaUtilLoggingTest {
31+
private static final boolean isExperimentalAttributesEnabled =
32+
Boolean.getBoolean("otel.instrumentation.java-util-logging.experimental-log-attributes");
3033

3134
private static final Logger logger = Logger.getLogger("abc");
3235

@@ -117,17 +120,25 @@ private static void test(
117120
if (logException) {
118121
assertThat(log)
119122
.hasAttributesSatisfyingExactly(
120-
equalTo(ThreadIncubatingAttributes.THREAD_NAME, Thread.currentThread().getName()),
121-
equalTo(ThreadIncubatingAttributes.THREAD_ID, Thread.currentThread().getId()),
123+
equalTo(
124+
ThreadIncubatingAttributes.THREAD_NAME,
125+
experimental(Thread.currentThread().getName())),
126+
equalTo(
127+
ThreadIncubatingAttributes.THREAD_ID,
128+
experimental(Thread.currentThread().getId())),
122129
equalTo(EXCEPTION_TYPE, IllegalStateException.class.getName()),
123130
equalTo(EXCEPTION_MESSAGE, "hello"),
124131
satisfies(
125132
EXCEPTION_STACKTRACE, v -> v.contains(JavaUtilLoggingTest.class.getName())));
126133
} else {
127134
assertThat(log)
128135
.hasAttributesSatisfyingExactly(
129-
equalTo(ThreadIncubatingAttributes.THREAD_NAME, Thread.currentThread().getName()),
130-
equalTo(ThreadIncubatingAttributes.THREAD_ID, Thread.currentThread().getId()));
136+
equalTo(
137+
ThreadIncubatingAttributes.THREAD_NAME,
138+
experimental(Thread.currentThread().getName())),
139+
equalTo(
140+
ThreadIncubatingAttributes.THREAD_ID,
141+
experimental(Thread.currentThread().getId())));
131142
}
132143

133144
if (withParent) {
@@ -164,4 +175,20 @@ private static void performLogging(
164175
interface LoggerMethod {
165176
void call(Logger logger, String msg);
166177
}
178+
179+
@Nullable
180+
public static String experimental(String value) {
181+
if (isExperimentalAttributesEnabled) {
182+
return value;
183+
}
184+
return null;
185+
}
186+
187+
@Nullable
188+
public static Long experimental(long value) {
189+
if (isExperimentalAttributesEnabled) {
190+
return value;
191+
}
192+
return null;
193+
}
167194
}
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1-
classification: internal
1+
display_name: Java Util Logging (JUL)
2+
description: This instrumentation bridges Java Util Logging (JUL) log records to OpenTelemetry logs.
3+
features:
4+
- LOGGING_BRIDGE
5+
library_link: https://docs.oracle.com/en/java/javase/11/docs/api/java.logging/java/util/logging/package-summary.html
6+
configurations:
7+
- name: otel.instrumentation.java-util-logging.experimental-log-attributes
8+
description: Enables capturing the experimental `thread.name` and `thread.id` log attributes.
9+
type: boolean
10+
default: false

0 commit comments

Comments
 (0)