Skip to content

Commit 5bb12b9

Browse files
Otel: set db.operation.name and db.system.name at span build time (#1091) (#1092)
* set db.operation.name and db.system.name at span build time * clean Co-authored-by: Laura Trotta <153528055+l-trotta@users.noreply.github.com>
1 parent bcea50c commit 5bb12b9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

java-client/src/main/java/co/elastic/clients/transport/instrumentation/OpenTelemetryForElasticsearch.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,13 @@ <TRequest> OTelContext(TRequest request, Endpoint<TRequest, ?, ?> endpoint) {
185185
}
186186
this.endpointId = endpointId;
187187

188-
span = tracer.spanBuilder(endpointId).setSpanKind(SpanKind.CLIENT).startSpan();
188+
span = tracer.spanBuilder(endpointId).setSpanKind(SpanKind.CLIENT)
189+
.setAttribute(ATTR_DB_SYSTEM, "elasticsearch")
190+
.setAttribute(ATTR_DB_OPERATION, endpointId)
191+
.startSpan();
192+
189193
if (span.isRecording()) {
190-
span.setAttribute(ATTR_DB_SYSTEM, "elasticsearch");
191-
span.setAttribute(ATTR_DB_OPERATION, endpointId);
194+
192195
span.setAttribute(ATTR_HTTP_REQUEST_METHOD, endpoint.method(request));
193196

194197
for (Map.Entry<String, String> pathParamEntry : endpoint.pathParameters(request).entrySet()) {

0 commit comments

Comments
 (0)