Skip to content

Commit 94ed87c

Browse files
Merge pull request #1 from dream-sports-labs/feat/fruits-of-labour
manually copy pasted everything by identifying the differences
2 parents 94ba3d8 + 134a719 commit 94ed87c

File tree

69 files changed

+4992
-28
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+4992
-28
lines changed

docs/instrumentation-list.yaml

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7618,6 +7618,211 @@ libraries:
76187618
target_versions:
76197619
javaagent:
76207620
- io.vertx:vertx-kafka-client:[3.5.1,)
7621+
- name: vertx-redis-client-3.7
7622+
source_path: instrumentation/vertx/vertx-redis-client-3.7
7623+
scope:
7624+
name: io.opentelemetry.vertx-redis-client-3.7
7625+
target_versions:
7626+
javaagent:
7627+
- io.vertx:vertx-redis-client:[3.7.0,3.8.0)
7628+
telemetry:
7629+
- when: default
7630+
spans:
7631+
- span_kind: CLIENT
7632+
attributes:
7633+
- name: db.operation
7634+
type: STRING
7635+
- name: db.redis.database_index
7636+
type: LONG
7637+
- name: db.statement
7638+
type: STRING
7639+
- name: db.system
7640+
type: STRING
7641+
- name: network.peer.address
7642+
type: STRING
7643+
- name: network.peer.port
7644+
type: LONG
7645+
- name: server.address
7646+
type: STRING
7647+
- name: server.port
7648+
type: LONG
7649+
- when: otel.semconv-stability.opt-in=database
7650+
metrics:
7651+
- name: db.client.operation.duration
7652+
description: Duration of database client operations.
7653+
type: HISTOGRAM
7654+
unit: s
7655+
attributes:
7656+
- name: db.namespace
7657+
type: STRING
7658+
- name: db.operation.name
7659+
type: STRING
7660+
- name: db.system.name
7661+
type: STRING
7662+
- name: network.peer.address
7663+
type: STRING
7664+
- name: network.peer.port
7665+
type: LONG
7666+
- name: server.address
7667+
type: STRING
7668+
- name: server.port
7669+
type: LONG
7670+
spans:
7671+
- span_kind: CLIENT
7672+
attributes:
7673+
- name: db.namespace
7674+
type: STRING
7675+
- name: db.operation.name
7676+
type: STRING
7677+
- name: db.query.text
7678+
type: STRING
7679+
- name: db.system.name
7680+
type: STRING
7681+
- name: network.peer.address
7682+
type: STRING
7683+
- name: network.peer.port
7684+
type: LONG
7685+
- name: server.address
7686+
type: STRING
7687+
- name: server.port
7688+
type: LONG
7689+
- name: vertx-redis-client-3.8
7690+
source_path: instrumentation/vertx/vertx-redis-client-3.8
7691+
scope:
7692+
name: io.opentelemetry.vertx-redis-client-3.8
7693+
target_versions:
7694+
javaagent:
7695+
- io.vertx:vertx-redis-client:[3.8.0,3.9.0)
7696+
telemetry:
7697+
- when: default
7698+
spans:
7699+
- span_kind: CLIENT
7700+
attributes:
7701+
- name: db.operation
7702+
type: STRING
7703+
- name: db.redis.database_index
7704+
type: LONG
7705+
- name: db.statement
7706+
type: STRING
7707+
- name: db.system
7708+
type: STRING
7709+
- name: network.peer.address
7710+
type: STRING
7711+
- name: network.peer.port
7712+
type: LONG
7713+
- name: server.address
7714+
type: STRING
7715+
- name: server.port
7716+
type: LONG
7717+
- when: otel.semconv-stability.opt-in=database
7718+
metrics:
7719+
- name: db.client.operation.duration
7720+
description: Duration of database client operations.
7721+
type: HISTOGRAM
7722+
unit: s
7723+
attributes:
7724+
- name: db.namespace
7725+
type: STRING
7726+
- name: db.operation.name
7727+
type: STRING
7728+
- name: db.system.name
7729+
type: STRING
7730+
- name: network.peer.address
7731+
type: STRING
7732+
- name: network.peer.port
7733+
type: LONG
7734+
- name: server.address
7735+
type: STRING
7736+
- name: server.port
7737+
type: LONG
7738+
spans:
7739+
- span_kind: CLIENT
7740+
attributes:
7741+
- name: db.namespace
7742+
type: STRING
7743+
- name: db.operation.name
7744+
type: STRING
7745+
- name: db.query.text
7746+
type: STRING
7747+
- name: db.system.name
7748+
type: STRING
7749+
- name: network.peer.address
7750+
type: STRING
7751+
- name: network.peer.port
7752+
type: LONG
7753+
- name: server.address
7754+
type: STRING
7755+
- name: server.port
7756+
type: LONG
7757+
- name: vertx-redis-client-3.9
7758+
description: This instrumentation enables Redis client spans for Vert.x Redis client 3.9.x versions, supporting both standalone and cluster modes.
7759+
source_path: instrumentation/vertx/vertx-redis-client-3.9
7760+
scope:
7761+
name: io.opentelemetry.vertx-redis-client-3.9
7762+
target_versions:
7763+
javaagent:
7764+
- io.vertx:vertx-redis-client:[3.9.1,4.0.0)
7765+
telemetry:
7766+
- when: default
7767+
spans:
7768+
- span_kind: CLIENT
7769+
attributes:
7770+
- name: db.operation
7771+
type: STRING
7772+
- name: db.redis.database_index
7773+
type: LONG
7774+
- name: db.statement
7775+
type: STRING
7776+
- name: db.system
7777+
type: STRING
7778+
- name: network.peer.address
7779+
type: STRING
7780+
- name: network.peer.port
7781+
type: LONG
7782+
- name: server.address
7783+
type: STRING
7784+
- name: server.port
7785+
type: LONG
7786+
- when: otel.semconv-stability.opt-in=database
7787+
metrics:
7788+
- name: db.client.operation.duration
7789+
description: Duration of database client operations.
7790+
type: HISTOGRAM
7791+
unit: s
7792+
attributes:
7793+
- name: db.namespace
7794+
type: STRING
7795+
- name: db.operation.name
7796+
type: STRING
7797+
- name: db.system.name
7798+
type: STRING
7799+
- name: network.peer.address
7800+
type: STRING
7801+
- name: network.peer.port
7802+
type: LONG
7803+
- name: server.address
7804+
type: STRING
7805+
- name: server.port
7806+
type: LONG
7807+
spans:
7808+
- span_kind: CLIENT
7809+
attributes:
7810+
- name: db.namespace
7811+
type: STRING
7812+
- name: db.operation.name
7813+
type: STRING
7814+
- name: db.query.text
7815+
type: STRING
7816+
- name: db.system.name
7817+
type: STRING
7818+
- name: network.peer.address
7819+
type: STRING
7820+
- name: network.peer.port
7821+
type: LONG
7822+
- name: server.address
7823+
type: STRING
7824+
- name: server.port
7825+
type: LONG
76217826
- name: vertx-redis-client-4.0
76227827
source_path: instrumentation/vertx/vertx-redis-client-4.0
76237828
scope:

instrumentation/cassandra/cassandra-3.0/javaagent/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ dependencies {
2727

2828
compileOnly("com.google.auto.value:auto-value-annotations")
2929
annotationProcessor("com.google.auto.value:auto-value")
30+
// Add Vertx dependency for context storage
31+
compileOnly("io.vertx:vertx-core:4.0.0")
32+
compileOnly("io.vertx:vertx-codegen:4.0.0")
3033

3134
testLibrary("com.datastax.cassandra:cassandra-driver-core:3.2.0")
3235
testInstrumentation(project(":instrumentation:guava-10.0:javaagent"))

instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/TracingSession.java

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import io.opentelemetry.context.Context;
2323
import io.opentelemetry.context.Scope;
2424
import java.util.Map;
25+
import io.vertx.core.Vertx;
2526

2627
public class TracingSession implements Session {
2728

@@ -49,7 +50,12 @@ public ListenableFuture<Session> initAsync() {
4950
@Override
5051
public ResultSet execute(String query) {
5152
CassandraRequest request = CassandraRequest.create(session, query);
52-
Context context = instrumenter().start(Context.current(), request);
53+
Context parentContext=Context.current();;
54+
io.vertx.core.Context storedContext = Vertx.currentContext();
55+
if((parentContext==null||parentContext==Context.root())&&storedContext!=null&&storedContext.get("otel.context")!=null&&storedContext.get("otel.context")!=Context.root()){
56+
parentContext=storedContext.get("otel.context");
57+
}
58+
Context context = instrumenter().start(parentContext, request);
5359
ResultSet resultSet;
5460
try (Scope ignored = context.makeCurrent()) {
5561
resultSet = session.execute(query);
@@ -64,7 +70,12 @@ public ResultSet execute(String query) {
6470
@Override
6571
public ResultSet execute(String query, Object... values) {
6672
CassandraRequest request = CassandraRequest.create(session, query);
67-
Context context = instrumenter().start(Context.current(), request);
73+
Context parentContext=Context.current();;
74+
io.vertx.core.Context storedContext = Vertx.currentContext();
75+
if((parentContext==null||parentContext==Context.root())&&storedContext!=null&&storedContext.get("otel.context")!=null&&storedContext.get("otel.context")!=Context.root()){
76+
parentContext=storedContext.get("otel.context");
77+
}
78+
Context context = instrumenter().start(parentContext, request);
6879
ResultSet resultSet;
6980
try (Scope ignored = context.makeCurrent()) {
7081
resultSet = session.execute(query, values);
@@ -79,7 +90,12 @@ public ResultSet execute(String query, Object... values) {
7990
@Override
8091
public ResultSet execute(String query, Map<String, Object> values) {
8192
CassandraRequest request = CassandraRequest.create(session, query);
82-
Context context = instrumenter().start(Context.current(), request);
93+
Context parentContext=Context.current();;
94+
io.vertx.core.Context storedContext = Vertx.currentContext();
95+
if((parentContext==null||parentContext==Context.root())&&storedContext!=null&&storedContext.get("otel.context")!=null&&storedContext.get("otel.context")!=Context.root()){
96+
parentContext=storedContext.get("otel.context");
97+
}
98+
Context context = instrumenter().start(parentContext, request);
8399
ResultSet resultSet;
84100
try (Scope ignored = context.makeCurrent()) {
85101
resultSet = session.execute(query, values);
@@ -95,7 +111,12 @@ public ResultSet execute(String query, Map<String, Object> values) {
95111
public ResultSet execute(Statement statement) {
96112
String query = getQuery(statement);
97113
CassandraRequest request = CassandraRequest.create(session, query);
98-
Context context = instrumenter().start(Context.current(), request);
114+
Context parentContext=Context.current();;
115+
io.vertx.core.Context storedContext = Vertx.currentContext();
116+
if((parentContext==null||parentContext==Context.root())&&storedContext!=null&&storedContext.get("otel.context")!=null&&storedContext.get("otel.context")!=Context.root()){
117+
parentContext=storedContext.get("otel.context");
118+
}
119+
Context context = instrumenter().start(parentContext, request);
99120
ResultSet resultSet;
100121
try (Scope ignored = context.makeCurrent()) {
101122
resultSet = session.execute(statement);
@@ -110,7 +131,12 @@ public ResultSet execute(Statement statement) {
110131
@Override
111132
public ResultSetFuture executeAsync(String query) {
112133
CassandraRequest request = CassandraRequest.create(session, query);
113-
Context context = instrumenter().start(Context.current(), request);
134+
Context parentContext=Context.current();;
135+
io.vertx.core.Context storedContext = Vertx.currentContext();
136+
if((parentContext==null||parentContext==Context.root())&&storedContext!=null&&storedContext.get("otel.context")!=null&&storedContext.get("otel.context")!=Context.root()){
137+
parentContext=storedContext.get("otel.context");
138+
}
139+
Context context = instrumenter().start(parentContext, request);
114140
try (Scope ignored = context.makeCurrent()) {
115141
ResultSetFuture future = session.executeAsync(query);
116142
addCallbackToEndSpan(future, context, request);
@@ -121,7 +147,12 @@ public ResultSetFuture executeAsync(String query) {
121147
@Override
122148
public ResultSetFuture executeAsync(String query, Object... values) {
123149
CassandraRequest request = CassandraRequest.create(session, query);
124-
Context context = instrumenter().start(Context.current(), request);
150+
Context parentContext=Context.current();;
151+
io.vertx.core.Context storedContext = Vertx.currentContext();
152+
if((parentContext==null||parentContext==Context.root())&&storedContext!=null&&storedContext.get("otel.context")!=null&&storedContext.get("otel.context")!=Context.root()){
153+
parentContext=storedContext.get("otel.context");
154+
}
155+
Context context = instrumenter().start(parentContext, request);
125156
try (Scope ignored = context.makeCurrent()) {
126157
ResultSetFuture future = session.executeAsync(query, values);
127158
addCallbackToEndSpan(future, context, request);
@@ -132,7 +163,12 @@ public ResultSetFuture executeAsync(String query, Object... values) {
132163
@Override
133164
public ResultSetFuture executeAsync(String query, Map<String, Object> values) {
134165
CassandraRequest request = CassandraRequest.create(session, query);
135-
Context context = instrumenter().start(Context.current(), request);
166+
Context parentContext=Context.current();;
167+
io.vertx.core.Context storedContext = Vertx.currentContext();
168+
if((parentContext==null||parentContext==Context.root())&&storedContext!=null&&storedContext.get("otel.context")!=null&&storedContext.get("otel.context")!=Context.root()){
169+
parentContext=storedContext.get("otel.context");
170+
}
171+
Context context = instrumenter().start(parentContext, request);
136172
try (Scope ignored = context.makeCurrent()) {
137173
ResultSetFuture future = session.executeAsync(query, values);
138174
addCallbackToEndSpan(future, context, request);
@@ -144,7 +180,12 @@ public ResultSetFuture executeAsync(String query, Map<String, Object> values) {
144180
public ResultSetFuture executeAsync(Statement statement) {
145181
String query = getQuery(statement);
146182
CassandraRequest request = CassandraRequest.create(session, query);
147-
Context context = instrumenter().start(Context.current(), request);
183+
Context parentContext=Context.current();;
184+
io.vertx.core.Context storedContext = Vertx.currentContext();
185+
if((parentContext==null||parentContext==Context.root())&&storedContext!=null&&storedContext.get("otel.context")!=null&&storedContext.get("otel.context")!=Context.root()){
186+
parentContext=storedContext.get("otel.context");
187+
}
188+
Context context = instrumenter().start(parentContext, request);
148189
try (Scope ignored = context.makeCurrent()) {
149190
ResultSetFuture future = session.executeAsync(statement);
150191
addCallbackToEndSpan(future, context, request);

instrumentation/netty/netty-4.1/library/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ dependencies {
77
implementation(project(":instrumentation:netty:netty-common-4.0:library"))
88
implementation(project(":instrumentation:netty:netty-common:library"))
99

10+
// Add Vertx dependency for context storage
11+
compileOnly("io.vertx:vertx-core:4.0.0")
12+
compileOnly("io.vertx:vertx-codegen:4.0.0")
13+
1014
compileOnly("com.google.auto.value:auto-value-annotations")
1115
annotationProcessor("com.google.auto.value:auto-value")
1216

instrumentation/netty/netty-4.1/library/src/main/java/io/opentelemetry/instrumentation/netty/v4_1/internal/client/HttpClientRequestTracingHandler.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
1818
import io.opentelemetry.instrumentation.netty.common.v4_0.HttpRequestAndChannel;
1919
import io.opentelemetry.instrumentation.netty.v4_1.internal.AttributeKeys;
20+
import io.vertx.core.Vertx;
2021

2122
/**
2223
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
@@ -42,10 +43,19 @@ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise prm) thr
4243
}
4344

4445
Context parentContext = ctx.channel().attr(AttributeKeys.CLIENT_PARENT_CONTEXT).get();
45-
if (parentContext == null) {
46+
if (parentContext == null||parentContext==Context.root()) {
4647
parentContext = Context.current();
4748
}
48-
49+
if (parentContext == null||parentContext==Context.root()) {
50+
io.vertx.core.Context vertxContext = Vertx.currentContext();
51+
if (vertxContext != null) {
52+
Context storedOtelContext =
53+
vertxContext.get("otel.context");
54+
if (storedOtelContext != null && storedOtelContext!=Context.root()) {
55+
parentContext = storedOtelContext;
56+
}
57+
}
58+
}
4959
HttpRequestAndChannel request = HttpRequestAndChannel.create((HttpRequest) msg, ctx.channel());
5060
if (!instrumenter.shouldStart(parentContext, request) || isAwsRequest(request)) {
5161
super.write(ctx, msg, prm);

0 commit comments

Comments
 (0)