Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions docs/instrumentation-list.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5820,22 +5820,141 @@ libraries:
- name: gen_ai.usage.output_tokens
type: LONG
opensearch:
- name: opensearch-java-3.0
description: |
This instrumentation enables database client spans and database client metrics for the OpenSearch Java client.
semantic_conventions:
- DATABASE_CLIENT_SPANS
- DATABASE_CLIENT_METRICS
library_link: https://docs.opensearch.org/latest/clients/java/
source_path: instrumentation/opensearch/opensearch-java-3.0
minimum_java_version: 11
scope:
name: io.opentelemetry.opensearch-java-3.0
target_versions:
javaagent:
- org.opensearch.client:opensearch-java:[3.0,)
telemetry:
- when: default
spans:
- span_kind: CLIENT
attributes:
- name: db.operation
type: STRING
- name: db.statement
type: STRING
- name: db.system
type: STRING
- when: otel.semconv-stability.opt-in=database
metrics:
- name: db.client.operation.duration
description: Duration of database client operations.
type: HISTOGRAM
unit: s
attributes:
- name: db.operation.name
type: STRING
- name: db.system.name
type: STRING
spans:
- span_kind: CLIENT
attributes:
- name: db.operation.name
type: STRING
- name: db.query.text
type: STRING
- name: db.system.name
type: STRING
- name: opensearch-rest-1.0
description: |
This instrumentation enables database client spans and database client metrics for OpenSearch REST clients.
semantic_conventions:
- DATABASE_CLIENT_SPANS
- DATABASE_CLIENT_METRICS
library_link: https://docs.opensearch.org/latest/clients/
source_path: instrumentation/opensearch/opensearch-rest-1.0
minimum_java_version: 11
scope:
name: io.opentelemetry.opensearch-rest-1.0
target_versions:
javaagent:
- org.opensearch.client:opensearch-rest-client:[1.0,3.0)
telemetry:
- when: default
spans:
- span_kind: CLIENT
attributes:
- name: db.operation
type: STRING
- name: db.statement
type: STRING
- name: db.system
type: STRING
- when: otel.semconv-stability.opt-in=database
metrics:
- name: db.client.operation.duration
description: Duration of database client operations.
type: HISTOGRAM
unit: s
attributes:
- name: db.operation.name
type: STRING
- name: db.system.name
type: STRING
spans:
- span_kind: CLIENT
attributes:
- name: db.operation.name
type: STRING
- name: db.query.text
type: STRING
- name: db.system.name
type: STRING
- name: opensearch-rest-3.0
description: |
This instrumentation enables database client spans and database client metrics for OpenSearch REST clients.
semantic_conventions:
- DATABASE_CLIENT_SPANS
- DATABASE_CLIENT_METRICS
library_link: https://docs.opensearch.org/latest/clients/
source_path: instrumentation/opensearch/opensearch-rest-3.0
minimum_java_version: 11
scope:
name: io.opentelemetry.opensearch-rest-3.0
target_versions:
javaagent:
- org.opensearch.client:opensearch-rest-client:[3.0,)
telemetry:
- when: default
spans:
- span_kind: CLIENT
attributes:
- name: db.operation
type: STRING
- name: db.statement
type: STRING
- name: db.system
type: STRING
- when: otel.semconv-stability.opt-in=database
metrics:
- name: db.client.operation.duration
description: Duration of database client operations.
type: HISTOGRAM
unit: s
attributes:
- name: db.operation.name
type: STRING
- name: db.system.name
type: STRING
spans:
- span_kind: CLIENT
attributes:
- name: db.operation.name
type: STRING
- name: db.query.text
type: STRING
- name: db.system.name
type: STRING
oracle:
- name: oracle-ucp-11.2
description: The Oracle Universal Connection Pool (UCP) instrumentation generates
Expand Down
6 changes: 6 additions & 0 deletions instrumentation-docs/instrumentations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ readonly INSTRUMENTATIONS=(
"okhttp:okhttp-2.2:javaagent:test"
"okhttp:okhttp-3.0:javaagent:test"
"openai:openai-java-1.1:javaagent:test"
"opensearch:opensearch-java-3.0:javaagent:test"
"opensearch:opensearch-java-3.0:javaagent:testStableSemconv"
"opensearch:opensearch-rest-1.0:javaagent:test"
"opensearch:opensearch-rest-1.0:javaagent:testStableSemconv"
"opensearch:opensearch-rest-3.0:javaagent:test"
"opensearch:opensearch-rest-3.0:javaagent:testStableSemconv"
"oshi:javaagent:test"
"oshi:javaagent:testExperimental"
"pekko:pekko-http-1.0:javaagent:test"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ dependencies {
}

tasks {
test {
withType<Test>().configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
systemProperty("collectMetadata", findProperty("collectMetadata")?.toString() ?: "false")
}

val testStableSemconv by registering(Test::class) {
testClassesDirs = sourceSets.test.get().output.classesDirs
classpath = sourceSets.test.get().runtimeClasspath
jvmArgs("-Dotel.semconv-stability.opt-in=database")
systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database")
}

check {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@

package io.opentelemetry.javaagent.instrumentation.opensearch.v3_0;

import static io.opentelemetry.instrumentation.testing.junit.db.DbClientMetricsTestUtil.assertDurationMetric;
import static io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil.maybeStable;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
import static io.opentelemetry.semconv.DbAttributes.DB_OPERATION_NAME;
import static io.opentelemetry.semconv.DbAttributes.DB_SYSTEM_NAME;
import static io.opentelemetry.semconv.HttpAttributes.HTTP_REQUEST_METHOD;
import static io.opentelemetry.semconv.HttpAttributes.HTTP_RESPONSE_STATUS_CODE;
import static io.opentelemetry.semconv.NetworkAttributes.NETWORK_PROTOCOL_VERSION;
Expand Down Expand Up @@ -151,4 +154,15 @@ void shouldGetStatusAsyncWithTraces() throws Exception {
.hasKind(SpanKind.INTERNAL)
.hasParent(trace.getSpan(1))));
}

@Test
void shouldRecordMetrics() throws IOException {
HealthResponse healthResponse = openSearchClient.cluster().health();
assertThat(healthResponse).isNotNull();

getTesting().waitForTraces(1);

assertDurationMetric(
getTesting(), "io.opentelemetry.opensearch-java-3.0", DB_OPERATION_NAME, DB_SYSTEM_NAME);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
description: >
This instrumentation enables database client spans and database client metrics for the OpenSearch
Java client.
library_link: https://docs.opensearch.org/latest/clients/java/
semantic_conventions:
- DATABASE_CLIENT_SPANS
- DATABASE_CLIENT_METRICS
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,16 @@ dependencies {
}

tasks {
test {
withType<Test>().configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
systemProperty("collectMetadata", findProperty("collectMetadata")?.toString() ?: "false")
}

val testStableSemconv by registering(Test::class) {
testClassesDirs = sourceSets.test.get().output.classesDirs
classpath = sourceSets.test.get().runtimeClasspath
jvmArgs("-Dotel.semconv-stability.opt-in=database")
systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database")
}

check {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,9 @@ protected RestClient buildRestClient() throws Exception {
protected int getResponseStatus(Response response) {
return response.getStatusLine().getStatusCode();
}

@Override
protected String getInstrumentationName() {
return "io.opentelemetry.opensearch-rest-1.0";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
description: >
This instrumentation enables database client spans and database client metrics for OpenSearch
REST clients.
library_link: https://docs.opensearch.org/latest/clients/
semantic_conventions:
- DATABASE_CLIENT_SPANS
- DATABASE_CLIENT_METRICS
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@ dependencies {
}

tasks {
test {
withType<Test>().configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
systemProperty("collectMetadata", findProperty("collectMetadata")?.toString() ?: "false")
}

val testStableSemconv by registering(Test::class) {
testClassesDirs = sourceSets.test.get().output.classesDirs
classpath = sourceSets.test.get().runtimeClasspath
jvmArgs("-Dotel.semconv-stability.opt-in=database")
systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database")
}

check {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,9 @@ protected RestClient buildRestClient() throws Exception {
protected int getResponseStatus(Response response) {
return response.getStatusLine().getStatusCode();
}

@Override
protected String getInstrumentationName() {
return "io.opentelemetry.opensearch-rest-3.0";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
description: >
This instrumentation enables database client spans and database client metrics for OpenSearch
REST clients.
library_link: https://docs.opensearch.org/latest/clients/
semantic_conventions:
- DATABASE_CLIENT_SPANS
- DATABASE_CLIENT_METRICS
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@

package io.opentelemetry.javaagent.instrumentation.opensearch.rest;

import static io.opentelemetry.instrumentation.testing.junit.db.DbClientMetricsTestUtil.assertDurationMetric;
import static io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil.maybeStable;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
import static io.opentelemetry.semconv.DbAttributes.DB_OPERATION_NAME;
import static io.opentelemetry.semconv.DbAttributes.DB_SYSTEM_NAME;
import static io.opentelemetry.semconv.HttpAttributes.HTTP_REQUEST_METHOD;
import static io.opentelemetry.semconv.HttpAttributes.HTTP_RESPONSE_STATUS_CODE;
import static io.opentelemetry.semconv.NetworkAttributes.NETWORK_PROTOCOL_VERSION;
Expand Down Expand Up @@ -49,6 +52,8 @@ public abstract class AbstractOpenSearchRestTest {

protected abstract int getResponseStatus(Response response);

protected abstract String getInstrumentationName();

@BeforeAll
void setUp() throws Exception {
opensearch =
Expand Down Expand Up @@ -169,4 +174,14 @@ public void onFailure(Exception e) {
.hasKind(SpanKind.INTERNAL)
.hasParent(trace.getSpan(0))));
}

@Test
void shouldRecordMetrics() throws IOException {
Response response = client.performRequest(new Request("GET", "_cluster/health"));
assertThat(getResponseStatus(response)).isEqualTo(200);

getTesting().waitForTraces(1);

assertDurationMetric(getTesting(), getInstrumentationName(), DB_OPERATION_NAME, DB_SYSTEM_NAME);
}
}
Loading