Skip to content

Commit a96be5a

Browse files
committed
error.type and db.response.status_code all dbs
1 parent 16f4bed commit a96be5a

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

instrumentation/vertx/vertx-sql-client-4.0/javaagent/build.gradle.kts

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ muzzle {
1313

1414
dependencies {
1515
library("io.vertx:vertx-sql-client:4.0.0")
16-
compileOnly("io.vertx:vertx-pg-client:4.0.0")
1716
compileOnly("io.vertx:vertx-codegen:4.0.0")
1817

1918
testInstrumentation(project(":instrumentation:netty:netty-4.1:javaagent"))

instrumentation/vertx/vertx-sql-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/sql/VertxSqlClientAttributesGetter.java

+11-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import static java.util.Collections.singleton;
99

1010
import io.opentelemetry.instrumentation.api.incubator.semconv.db.SqlClientAttributesGetter;
11-
import io.vertx.pgclient.PgException;
11+
import java.lang.reflect.InvocationTargetException;
1212
import java.util.Collection;
1313
import javax.annotation.Nullable;
1414

@@ -49,8 +49,16 @@ public Collection<String> getRawQueryTexts(VertxSqlClientRequest request) {
4949
@Nullable
5050
@Override
5151
public String getResponseStatusFromException(Throwable throwable) {
52-
if (throwable instanceof PgException) {
53-
return ((PgException) throwable).getCode();
52+
try {
53+
Class<?> ex = Class.forName("io.vertx.pgclient.PgException");
54+
if (ex.isInstance(throwable)) {
55+
return (String) ex.getMethod("getCode").invoke(throwable);
56+
}
57+
} catch (ClassNotFoundException
58+
| NoSuchMethodException
59+
| IllegalAccessException
60+
| InvocationTargetException e) {
61+
return null;
5462
}
5563
return null;
5664
}

0 commit comments

Comments
 (0)