diff --git a/instrumentation/elasticsearch/elasticsearch-api-client-8.0/javaagent/src/test/java/ElasticsearchClient8Test.java b/instrumentation/elasticsearch/elasticsearch-api-client-8.0/javaagent/src/test/java/ElasticsearchClient8Test.java index c44d53e98f39..e2cae53cb7ab 100644 --- a/instrumentation/elasticsearch/elasticsearch-api-client-8.0/javaagent/src/test/java/ElasticsearchClient8Test.java +++ b/instrumentation/elasticsearch/elasticsearch-api-client-8.0/javaagent/src/test/java/ElasticsearchClient8Test.java @@ -96,9 +96,7 @@ public void elasticsearchStatus() throws IOException { equalTo(AttributeKey.stringKey("net.protocol.version"), "1.1"), equalTo(SemanticAttributes.HTTP_URL, httpHost.toURI() + "/"), equalTo(SemanticAttributes.HTTP_STATUS_CODE, 200L), - equalTo(SemanticAttributes.USER_AGENT_ORIGINAL, - "elastic-java/" + RestClientBuilder.VERSION + " (Java/" - + System.getProperty("java.version") + ")"), + equalTo(SemanticAttributes.USER_AGENT_ORIGINAL, userAgent()), satisfies(SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH, AbstractLongAssert::isPositive) ) @@ -144,15 +142,18 @@ public void elasticsearchIndex() throws IOException { equalTo(SemanticAttributes.HTTP_URL, httpHost.toURI() + "/test-index/_doc/test-id?timeout=1s"), equalTo(SemanticAttributes.HTTP_STATUS_CODE, 201L), - equalTo(SemanticAttributes.USER_AGENT_ORIGINAL, - "elastic-java/" + RestClientBuilder.VERSION + " (Java/" - + System.getProperty("java.version") + ")"), + equalTo(SemanticAttributes.USER_AGENT_ORIGINAL, userAgent()), satisfies(SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH, AbstractLongAssert::isPositive) ) )); } + private static String userAgent() { + return "elastic-java/" + RestClientBuilder.VERSION + " (Java/" + + System.getProperty("java.version") + ")"; + } + private static class Person { public final String name;