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
296 changes: 296 additions & 0 deletions docs/instrumentation-list.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8250,6 +8250,13 @@ libraries:
- io.micrometer:micrometer-core:1.5.0
mongo:
- name: mongo-3.1
display_name: MongoDB Driver
description: |
This instrumentation enables database client spans and database client metrics for the MongoDB Java driver.
semantic_conventions:
- DATABASE_CLIENT_SPANS
- DATABASE_CLIENT_METRICS
library_link: https://www.mongodb.com/docs/drivers/java-drivers/
source_path: instrumentation/mongo/mongo-3.1
scope:
name: io.opentelemetry.mongo-3.1
Expand All @@ -8258,28 +8265,317 @@ libraries:
- org.mongodb:mongo-java-driver:[3.1,)
library:
- org.mongodb:mongo-java-driver:3.1.0
configurations:
- name: otel.instrumentation.mongo.statement-sanitizer.enabled
description: |
Enables statement sanitization for MongoDB queries. Takes precedence over otel.instrumentation.common.db-statement-sanitizer.enabled.
type: boolean
default: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should default to the value of otel.instrumentation.common.db-statement-sanitizer.enabled but using true should be fine too

- name: otel.instrumentation.common.db-statement-sanitizer.enabled
description: Enables statement sanitization for database queries.
type: boolean
default: true
telemetry:
- when: default
spans:
- span_kind: CLIENT
attributes:
- name: db.connection_string
type: STRING
- name: db.mongodb.collection
type: STRING
- name: db.name
type: STRING
- name: db.operation
type: STRING
- name: db.statement
type: STRING
- name: db.system
type: STRING
- name: server.address
type: STRING
- name: server.port
type: LONG
- 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.collection.name
type: STRING
- name: db.namespace
type: STRING
- name: db.operation.name
type: STRING
- name: db.system.name
type: STRING
- name: server.address
type: STRING
- name: server.port
type: LONG
spans:
- span_kind: CLIENT
attributes:
- name: db.collection.name
type: STRING
- name: db.namespace
type: STRING
- name: db.operation.name
type: STRING
- name: db.query.text
type: STRING
- name: db.system.name
type: STRING
- name: server.address
type: STRING
- name: server.port
type: LONG
- name: mongo-3.7
display_name: MongoDB Driver
description: |
This instrumentation enables database client spans and database client metrics for the MongoDB Java driver.
semantic_conventions:
- DATABASE_CLIENT_SPANS
- DATABASE_CLIENT_METRICS
library_link: https://www.mongodb.com/docs/drivers/java-drivers/
source_path: instrumentation/mongo/mongo-3.7
scope:
name: io.opentelemetry.mongo-3.7
target_versions:
javaagent:
- org.mongodb:mongodb-driver-core:[3.7, 4.0)
- org.mongodb:mongo-java-driver:[3.7, 4.0)
configurations:
- name: otel.instrumentation.mongo.statement-sanitizer.enabled
description: |
Enables statement sanitization for MongoDB queries. Takes precedence over otel.instrumentation.common.db-statement-sanitizer.enabled.
type: boolean
default: true
- name: otel.instrumentation.common.db-statement-sanitizer.enabled
description: Enables statement sanitization for database queries.
type: boolean
default: true
telemetry:
- when: default
spans:
- span_kind: CLIENT
attributes:
- name: db.connection_string
type: STRING
- name: db.mongodb.collection
type: STRING
- name: db.name
type: STRING
- name: db.operation
type: STRING
- name: db.statement
type: STRING
- name: db.system
type: STRING
- name: server.address
type: STRING
- name: server.port
type: LONG
- 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.collection.name
type: STRING
- name: db.namespace
type: STRING
- name: db.operation.name
type: STRING
- name: db.system.name
type: STRING
- name: server.address
type: STRING
- name: server.port
type: LONG
spans:
- span_kind: CLIENT
attributes:
- name: db.collection.name
type: STRING
- name: db.namespace
type: STRING
- name: db.operation.name
type: STRING
- name: db.query.text
type: STRING
- name: db.system.name
type: STRING
- name: server.address
type: STRING
- name: server.port
type: LONG
- name: mongo-4.0
display_name: MongoDB Driver
description: |
This instrumentation enables database client spans and database client metrics for the MongoDB Java driver.
semantic_conventions:
- DATABASE_CLIENT_SPANS
- DATABASE_CLIENT_METRICS
library_link: https://www.mongodb.com/docs/drivers/java-drivers/
source_path: instrumentation/mongo/mongo-4.0
scope:
name: io.opentelemetry.mongo-4.0
target_versions:
javaagent:
- org.mongodb:mongodb-driver-core:[4.0,)
configurations:
- name: otel.instrumentation.mongo.statement-sanitizer.enabled
description: |
Enables statement sanitization for MongoDB queries. Takes precedence over otel.instrumentation.common.db-statement-sanitizer.enabled.
type: boolean
default: true
- name: otel.instrumentation.common.db-statement-sanitizer.enabled
description: Enables statement sanitization for database queries.
type: boolean
default: true
telemetry:
- when: default
spans:
- span_kind: CLIENT
attributes:
- name: db.connection_string
type: STRING
- name: db.mongodb.collection
type: STRING
- name: db.name
type: STRING
- name: db.operation
type: STRING
- name: db.statement
type: STRING
- name: db.system
type: STRING
- name: server.address
type: STRING
- name: server.port
type: LONG
- 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.collection.name
type: STRING
- name: db.namespace
type: STRING
- name: db.operation.name
type: STRING
- name: db.system.name
type: STRING
- name: server.address
type: STRING
- name: server.port
type: LONG
spans:
- span_kind: CLIENT
attributes:
- name: db.collection.name
type: STRING
- name: db.namespace
type: STRING
- name: db.operation.name
type: STRING
- name: db.query.text
type: STRING
- name: db.system.name
type: STRING
- name: server.address
type: STRING
- name: server.port
type: LONG
- name: mongo-async-3.3
display_name: MongoDB Driver (Async)
description: |
This instrumentation enables database client spans and database client metrics for the MongoDB async Java driver.
semantic_conventions:
- DATABASE_CLIENT_SPANS
- DATABASE_CLIENT_METRICS
library_link: https://www.mongodb.com/docs/drivers/java-drivers/
source_path: instrumentation/mongo/mongo-async-3.3
scope:
name: io.opentelemetry.mongo-async-3.3
target_versions:
javaagent:
- org.mongodb:mongodb-driver-async:[3.3,)
configurations:
- name: otel.instrumentation.mongo.statement-sanitizer.enabled
description: |
Enables statement sanitization for MongoDB queries. Takes precedence over otel.instrumentation.common.db-statement-sanitizer.enabled.
type: boolean
default: true
- name: otel.instrumentation.common.db-statement-sanitizer.enabled
description: Enables statement sanitization for database queries.
type: boolean
default: true
telemetry:
- when: default
spans:
- span_kind: CLIENT
attributes:
- name: db.connection_string
type: STRING
- name: db.mongodb.collection
type: STRING
- name: db.name
type: STRING
- name: db.operation
type: STRING
- name: db.statement
type: STRING
- name: db.system
type: STRING
- name: server.address
type: STRING
- name: server.port
type: LONG
- 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.collection.name
type: STRING
- name: db.namespace
type: STRING
- name: db.operation.name
type: STRING
- name: db.system.name
type: STRING
- name: server.address
type: STRING
- name: server.port
type: LONG
spans:
- span_kind: CLIENT
attributes:
- name: db.collection.name
type: STRING
- name: db.namespace
type: STRING
- name: db.operation.name
type: STRING
- name: db.query.text
type: STRING
- name: db.system.name
type: STRING
- name: server.address
type: STRING
- name: server.port
type: LONG
mybatis:
- name: mybatis-3.2
display_name: MyBatis
Expand Down
8 changes: 8 additions & 0 deletions instrumentation-docs/instrumentations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,14 @@ readonly INSTRUMENTATIONS=(
"lettuce:lettuce-5.0:javaagent:testStableSemconv"
"lettuce:lettuce-5.1:javaagent:test"
"lettuce:lettuce-5.1:javaagent:testStableSemconv"
"mongo:mongo-3.1:javaagent:test"
"mongo:mongo-3.1:javaagent:testStableSemconv"
"mongo:mongo-3.7:javaagent:test"
"mongo:mongo-3.7:javaagent:testStableSemconv"
"mongo:mongo-4.0:javaagent:test"
"mongo:mongo-4.0:javaagent:testStableSemconv"
"mongo:mongo-async-3.3:javaagent:test"
"mongo:mongo-async-3.3:javaagent:testStableSemconv"
"mybatis-3.2:javaagent:test"
"nats:nats-2.17:javaagent:test"
"nats:nats-2.17:javaagent:testExperimental"
Expand Down
2 changes: 2 additions & 0 deletions instrumentation/mongo/mongo-3.1/javaagent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ dependencies {
tasks {
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 @@ -6,22 +6,26 @@
package io.opentelemetry.javaagent.instrumentation.mongo.v3_1;

import com.mongodb.event.CommandListener;
import com.mongodb.event.CommandStartedEvent;
import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.instrumentation.mongo.v3_1.MongoTelemetry;
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.instrumentation.mongo.v3_1.internal.MongoInstrumenterFactory;
import io.opentelemetry.instrumentation.mongo.v3_1.internal.TracingCommandListener;
import io.opentelemetry.javaagent.bootstrap.internal.AgentCommonConfig;
import io.opentelemetry.javaagent.bootstrap.internal.AgentInstrumentationConfig;

public final class MongoInstrumentationSingletons {

public static final CommandListener LISTENER =
MongoTelemetry.builder(GlobalOpenTelemetry.get())
.setStatementSanitizationEnabled(
AgentInstrumentationConfig.get()
.getBoolean(
"otel.instrumentation.mongo.statement-sanitizer.enabled",
AgentCommonConfig.get().isStatementSanitizationEnabled()))
.build()
.newCommandListener();
private static final Instrumenter<CommandStartedEvent, Void> INSTRUMENTER =
MongoInstrumenterFactory.createInstrumenter(
GlobalOpenTelemetry.get(),
"io.opentelemetry.mongo-3.1",
AgentInstrumentationConfig.get()
.getBoolean(
"otel.instrumentation.mongo.statement-sanitizer.enabled",
AgentCommonConfig.get().isStatementSanitizationEnabled()));

public static final CommandListener LISTENER = new TracingCommandListener(INSTRUMENTER);

public static boolean isTracingListener(CommandListener listener) {
return listener.getClass().getName().equals(LISTENER.getClass().getName());
Expand Down
Loading
Loading