diff --git a/server/src/main/java/org/opensearch/telemetry/tracing/SpanBuilder.java b/server/src/main/java/org/opensearch/telemetry/tracing/SpanBuilder.java index b31b5699e93e3..87fe0ddd4f568 100644 --- a/server/src/main/java/org/opensearch/telemetry/tracing/SpanBuilder.java +++ b/server/src/main/java/org/opensearch/telemetry/tracing/SpanBuilder.java @@ -157,14 +157,14 @@ private static Attributes buildSpanAttributes(String action, TcpChannel tcpChann } private static Attributes buildSpanAttributes(String nodeId, ReplicatedWriteRequest request) { - Attributes attributes = Attributes.create().addAttribute(AttributeNames.NODE_ID, nodeId); + Attributes attributes = Attributes.create().addAttribute(AttributeNames.NODE_ID, nodeId) + .addAttribute(AttributeNames.REFRESH_POLICY, request.getRefreshPolicy().getValue()); + if (request.shardId() != null) { + attributes.addAttribute(AttributeNames.INDEX, request.shardId().getIndexName()) + .addAttribute(AttributeNames.SHARD_ID, request.shardId().getId()); + } if (request instanceof BulkShardRequest) { - attributes.addAttribute(AttributeNames.BULK_REQUEST_ITEMS, ((BulkShardRequest) request).items().length) - .addAttribute(AttributeNames.REFRESH_POLICY, request.getRefreshPolicy().getValue()); - if (request.shardId() != null) { - attributes.addAttribute(AttributeNames.INDEX, request.shardId().getIndexName()) - .addAttribute(AttributeNames.SHARD_ID, request.shardId().getId()); - } + attributes.addAttribute(AttributeNames.BULK_REQUEST_ITEMS, ((BulkShardRequest) request).items().length); } return attributes; }