Skip to content

Commit b3f6bc0

Browse files
committed
Extract onEndCommon
1 parent a228abb commit b3f6bc0

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractor.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ public void onEnd(
8585
REQUEST request,
8686
@Nullable RESPONSE response,
8787
@Nullable Throwable error) {
88+
onEndCommon(attributes, getter, response, error);
89+
}
90+
91+
static <REQUEST, RESPONSE> void onEndCommon(
92+
AttributesBuilder attributes,
93+
DbClientAttributesGetter<REQUEST, RESPONSE> getter,
94+
@Nullable RESPONSE response,
95+
@Nullable Throwable error) {
8896
if (SemconvStability.emitStableDatabaseSemconv()) {
8997
if (error != null) {
9098
internalSet(attributes, ERROR_TYPE, error.getClass().getName());

instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,7 @@ public void onEnd(
195195
REQUEST request,
196196
@Nullable RESPONSE response,
197197
@Nullable Throwable error) {
198-
if (SemconvStability.emitStableDatabaseSemconv()) {
199-
if (error != null) {
200-
internalSet(attributes, ERROR_TYPE, error.getClass().getName());
201-
}
202-
if (error != null || response != null) {
203-
internalSet(attributes, DB_RESPONSE_STATUS_CODE, getter.getResponseStatus(response, error));
204-
}
205-
}
198+
DbClientAttributesExtractor.onEndCommon(attributes, getter, response, error);
206199
}
207200

208201
/**

0 commit comments

Comments
 (0)