Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
128 changes: 117 additions & 11 deletions docs/instrumentation-list.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2082,19 +2082,52 @@ libraries:
type: LONG
couchbase:
- name: couchbase-2.0
description: |
This instrumentation enables database CLIENT spans and metrics for Couchbase 2.0 operations. It automatically traces key-value operations (get, upsert, replace, remove), view queries, N1QL queries, and cluster management operations.
source_path: instrumentation/couchbase/couchbase-2.0
scope:
name: io.opentelemetry.couchbase-2.0
target_versions:
javaagent:
- com.couchbase.client:java-client:[2,3)
configurations:
- name: otel.instrumentation.couchbase.experimental-span-attributes
Copy link
Member Author

Choose a reason for hiding this comment

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

this removal was intentional. while the 2.0 instrumenter has the attributeextractor, it only works within the 2.6 instrumentation, so it made sense to me to remove it from being documented here

description: Enables experimental span attributes `couchbase.operation_id` and
`couchbase.local.address`
type: boolean
default: false
telemetry:
- when: default
spans:
- span_kind: CLIENT
attributes:
- name: db.name
type: STRING
- 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.namespace
type: STRING
- name: db.operation.name
type: STRING
- name: db.query.text
type: STRING
- name: db.system.name
type: STRING
- name: couchbase-2.6
description: |
This instrumentation enables database CLIENT spans and metrics for Couchbase 2.6 operations. It automatically traces key-value operations (get, upsert, replace, remove), view queries, N1QL queries, and cluster management operations.
source_path: instrumentation/couchbase/couchbase-2.6
scope:
name: io.opentelemetry.couchbase-2.6
Expand All @@ -2103,13 +2136,86 @@ libraries:
- com.couchbase.client:java-client:[2.6.0,3)
configurations:
- name: otel.instrumentation.couchbase.experimental-span-attributes
description: Enables experimental span attributes couchbase.operation_id and
couchbase.local.address
description: |
Enables experimental span attributes `couchbase.operation_id` and `couchbase.local.address`. Different operation types receive different experimental attributes.
type: boolean
default: false
telemetry:
- when: default
spans:
- span_kind: CLIENT
attributes:
- name: db.name
type: STRING
- name: db.operation
type: STRING
- name: db.statement
type: STRING
- name: db.system
type: STRING
- name: network.peer.address
type: STRING
- name: network.peer.port
type: LONG
- name: network.type
type: STRING
- when: otel.instrumentation.couchbase.experimental-span-attributes=true
spans:
- span_kind: CLIENT
attributes:
- name: couchbase.local.address
type: STRING
- name: couchbase.operation_id
type: STRING
- name: db.name
type: STRING
- name: db.operation
type: STRING
- name: db.statement
type: STRING
- name: db.system
type: STRING
- name: network.peer.address
type: STRING
- name: network.peer.port
type: LONG
- name: network.type
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
- name: network.peer.address
type: STRING
- name: network.peer.port
type: LONG
spans:
- span_kind: CLIENT
attributes:
- name: db.namespace
type: STRING
- name: db.operation.name
type: STRING
- name: db.query.text
type: STRING
- name: db.system.name
type: STRING
- name: network.peer.address
type: STRING
- name: network.peer.port
type: LONG
- name: network.type
type: STRING
- name: couchbase-3.1
description: |
Couchbase instrumentation is owned by the Couchbase project. This instrumentation automatically configures the instrumentation provided by the Couchbase library.
Couchbase instrumentation is owned by the Couchbase project for versions 3+. This instrumentation automatically configures the instrumentation provided by the Couchbase library.
source_path: instrumentation/couchbase/couchbase-3.1
scope:
name: io.opentelemetry.couchbase-3.1
Expand All @@ -2118,7 +2224,7 @@ libraries:
- com.couchbase.client:java-client:[3.1,3.1.6)
- name: couchbase-3.1.6
description: |
Couchbase instrumentation is owned by the Couchbase project. This instrumentation automatically configures the instrumentation provided by the Couchbase library.
Couchbase instrumentation is owned by the Couchbase project for versions 3+. This instrumentation automatically configures the instrumentation provided by the Couchbase library.
source_path: instrumentation/couchbase/couchbase-3.1.6
scope:
name: io.opentelemetry.couchbase-3.1.6
Expand All @@ -2127,7 +2233,7 @@ libraries:
- com.couchbase.client:java-client:[3.1.6,3.2.0)
- name: couchbase-3.2
description: |
Couchbase instrumentation is owned by the Couchbase project. This instrumentation automatically configures the instrumentation provided by the Couchbase library.
Couchbase instrumentation is owned by the Couchbase project for versions 3+. This instrumentation automatically configures the instrumentation provided by the Couchbase library.
source_path: instrumentation/couchbase/couchbase-3.2
scope:
name: io.opentelemetry.couchbase-3.2
Expand Down
5 changes: 5 additions & 0 deletions instrumentation-docs/instrumentations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ readonly INSTRUMENTATIONS=(
"camel-2.20:javaagent:test"
"camel-2.20:javaagent:testStableSemconv"
"camel-2.20:javaagent:testExperimental"
"couchbase:couchbase-2.0:javaagent:test"
"couchbase:couchbase-2.0:javaagent:testStableSemconv"
"couchbase:couchbase-2.6:javaagent:test"
"couchbase:couchbase-2.6:javaagent:testStableSemconv"
"couchbase:couchbase-2.6:javaagent:testExperimental"
)

# Some instrumentation test suites don't run ARM, so we use colima to run them in an x86_64
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ class TelemetryParser {

// Key is the scope of the module being analyzed, value is a set of additional allowed scopes.
private static final Map<String, Set<String>> scopeAllowList =
Map.of("io.opentelemetry.armeria-grpc-1.14", Set.of("io.opentelemetry.grpc-1.6"));
Map.of(
// armeria-grpc uses grpc-1.6 instrumenter.
"io.opentelemetry.armeria-grpc-1.14", Set.of("io.opentelemetry.grpc-1.6"),
// couchbase-2.6 extends couchbase-2.0 instrumentation with more attributes.
"io.opentelemetry.couchbase-2.6", Set.of("io.opentelemetry.couchbase-2.0"));

/**
* Checks if the given telemetry scope is valid for the specified module scope.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@ tasks {
jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED")
jvmArgs("--add-opens=java.base/java.lang.invoke=ALL-UNNAMED")
jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")

systemProperty("collectMetadata", findProperty("collectMetadata")?.toString() ?: "false")
}

val testStableSemconv by registering(Test::class) {
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 @@ -8,6 +8,8 @@
import com.couchbase.client.java.cluster.BucketSettings;
import com.couchbase.client.java.env.DefaultCouchbaseEnvironment;
import io.opentelemetry.instrumentation.couchbase.AbstractCouchbaseAsyncClientTest;
import io.opentelemetry.sdk.testing.assertj.AttributeAssertion;
import java.util.List;

class CouchbaseAsyncClientTest extends AbstractCouchbaseAsyncClientTest {

Expand All @@ -16,4 +18,24 @@ protected DefaultCouchbaseEnvironment.Builder envBuilder(
BucketSettings bucketSettings, int carrierDirectPort, int httpDirectPort) {
return CouchbaseUtil.envBuilder(bucketSettings, carrierDirectPort, httpDirectPort);
}

@Override
protected List<AttributeAssertion> couchbaseAttributes() {
return CouchbaseUtil.couchbaseAttributes();
}

@Override
protected List<AttributeAssertion> couchbaseQueryAttributes() {
return CouchbaseUtil.couchbaseQueryAttributes();
}

@Override
protected List<AttributeAssertion> couchbaseClusterManagerAttributes() {
return CouchbaseUtil.couchbaseClusterManagerAttributes();
}

@Override
protected List<AttributeAssertion> couchbaseN1qlAttributes() {
return CouchbaseUtil.couchbaseN1qlAttributes();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,19 @@

package io.opentelemetry.javaagent.instrumentation.couchbase.v2_0;

import static io.opentelemetry.instrumentation.testing.junit.db.DbClientMetricsTestUtil.assertDurationMetric;
import static io.opentelemetry.semconv.DbAttributes.DB_OPERATION_NAME;
import static io.opentelemetry.semconv.DbAttributes.DB_SYSTEM_NAME;
import static org.assertj.core.api.Assertions.assertThat;

import com.couchbase.client.java.CouchbaseCluster;
import com.couchbase.client.java.cluster.BucketSettings;
import com.couchbase.client.java.cluster.ClusterManager;
import com.couchbase.client.java.env.DefaultCouchbaseEnvironment;
import io.opentelemetry.instrumentation.couchbase.AbstractCouchbaseClientTest;
import io.opentelemetry.sdk.testing.assertj.AttributeAssertion;
import java.util.List;
import org.junit.jupiter.api.Test;

class CouchbaseClientTest extends AbstractCouchbaseClientTest {

Expand All @@ -16,4 +26,39 @@ protected DefaultCouchbaseEnvironment.Builder envBuilder(
BucketSettings bucketSettings, int carrierDirectPort, int httpDirectPort) {
return CouchbaseUtil.envBuilder(bucketSettings, carrierDirectPort, httpDirectPort);
}

@Override
protected List<AttributeAssertion> couchbaseAttributes() {
return CouchbaseUtil.couchbaseAttributes();
}

@Override
protected List<AttributeAssertion> couchbaseQueryAttributes() {
return CouchbaseUtil.couchbaseQueryAttributes();
}

@Override
protected List<AttributeAssertion> couchbaseClusterManagerAttributes() {
return CouchbaseUtil.couchbaseClusterManagerAttributes();
}

@Override
protected List<AttributeAssertion> couchbaseN1qlAttributes() {
return CouchbaseUtil.couchbaseN1qlAttributes();
}

@Test
void hasDurationMetric() {
CouchbaseCluster cluster = prepareCluster(bucketCouchbase);
ClusterManager manager = cluster.clusterManager(USERNAME, PASSWORD);

testing.waitForTraces(1);
testing.clearData();

boolean hasBucket = manager.hasBucket(bucketCouchbase.name());
assertThat(hasBucket).isTrue();

assertDurationMetric(
testing, "io.opentelemetry.couchbase-2.0", DB_SYSTEM_NAME, DB_OPERATION_NAME);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,38 @@

package io.opentelemetry.javaagent.instrumentation.couchbase.v2_0;

import static java.util.Collections.emptyList;

import com.couchbase.client.core.metrics.DefaultLatencyMetricsCollectorConfig;
import com.couchbase.client.core.metrics.DefaultMetricsCollectorConfig;
import com.couchbase.client.java.cluster.BucketSettings;
import com.couchbase.client.java.env.DefaultCouchbaseEnvironment;
import io.opentelemetry.sdk.testing.assertj.AttributeAssertion;
import java.util.List;
import java.util.concurrent.TimeUnit;

public class CouchbaseUtil {

public static List<AttributeAssertion> couchbaseAttributes() {
return couchbaseKvAttributes();
}

public static List<AttributeAssertion> couchbaseKvAttributes() {
return emptyList();
}

public static List<AttributeAssertion> couchbaseQueryAttributes() {
return emptyList();
}

public static List<AttributeAssertion> couchbaseClusterManagerAttributes() {
return emptyList();
}

public static List<AttributeAssertion> couchbaseN1qlAttributes() {
return emptyList();
}

public static DefaultCouchbaseEnvironment.Builder envBuilder(
BucketSettings bucketSettings, int carrierDirectPort, int httpDirectPort) {
// Couchbase seems to be really slow to start sometimes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import io.opentelemetry.instrumentation.couchbase.springdata.TestDocument;
import io.opentelemetry.instrumentation.couchbase.springdata.TestRepository;
import io.opentelemetry.javaagent.instrumentation.couchbase.v2_0.CouchbaseUtil;
import io.opentelemetry.sdk.testing.assertj.AttributeAssertion;
import java.util.List;

class CouchbaseSpringRepositoryTest extends AbstractCouchbaseSpringRepositoryTest {

Expand All @@ -20,6 +22,26 @@ protected DefaultCouchbaseEnvironment.Builder envBuilder(
return CouchbaseUtil.envBuilder(bucketSettings, carrierDirectPort, httpDirectPort);
}

@Override
protected List<AttributeAssertion> couchbaseAttributes() {
return CouchbaseUtil.couchbaseAttributes();
}

@Override
protected List<AttributeAssertion> couchbaseQueryAttributes() {
return CouchbaseUtil.couchbaseQueryAttributes();
}

@Override
protected List<AttributeAssertion> couchbaseClusterManagerAttributes() {
return CouchbaseUtil.couchbaseClusterManagerAttributes();
}

@Override
protected List<AttributeAssertion> couchbaseN1qlAttributes() {
return CouchbaseUtil.couchbaseN1qlAttributes();
}

@Override
protected TestDocument findById(TestRepository repository, String id) {
return repository.findOne(id);
Expand Down
Loading