Skip to content

Commit

Permalink
error.type and db.response.status_code all dbs
Browse files Browse the repository at this point in the history
  • Loading branch information
zeitlinger committed Feb 24, 2025
1 parent 7454b42 commit b33510e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ muzzle {

dependencies {
library("io.vertx:vertx-sql-client:4.0.0")
compileOnly("io.vertx:vertx-pg-client:4.0.0")
compileOnly("io.vertx:vertx-codegen:4.0.0")

testInstrumentation(project(":instrumentation:netty:netty-4.1:javaagent"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import static java.util.Collections.singleton;

import io.opentelemetry.instrumentation.api.incubator.semconv.db.SqlClientAttributesGetter;
import io.vertx.pgclient.PgException;
import java.lang.reflect.InvocationTargetException;
import java.util.Collection;
import javax.annotation.Nullable;

Expand Down Expand Up @@ -49,8 +49,16 @@ public Collection<String> getRawQueryTexts(VertxSqlClientRequest request) {
@Nullable
@Override
public String getResponseStatusFromException(Throwable throwable) {
if (throwable instanceof PgException) {
return ((PgException) throwable).getCode();
try {
Class<?> ex = Class.forName("io.vertx.pgclient.PgException");
if (ex.isInstance(throwable)) {
return (String) ex.getMethod("getCode").invoke(throwable);
}
} catch (ClassNotFoundException
| NoSuchMethodException
| IllegalAccessException
| InvocationTargetException e) {
return null;
}
return null;
}
Expand Down

0 comments on commit b33510e

Please sign in to comment.