Skip to content

Commit

Permalink
fixed style
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Wert <[email protected]>
  • Loading branch information
AlexanderWert committed Jun 26, 2023
1 parent 2592d6a commit befc456
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@
* SPDX-License-Identifier: Apache-2.0
*/

import static io.opentelemetry.instrumentation.testing.GlobalTraceUtil.runWithSpan;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.satisfies;

import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.apache.http.HttpHost;
import org.assertj.core.api.AbstractLongAssert;
import org.elasticsearch.client.Request;
Expand All @@ -21,13 +28,6 @@
import org.junit.jupiter.api.extension.RegisterExtension;
import org.testcontainers.elasticsearch.ElasticsearchContainer;
import org.testcontainers.shaded.com.fasterxml.jackson.databind.ObjectMapper;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import static io.opentelemetry.instrumentation.testing.GlobalTraceUtil.runWithSpan;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.satisfies;

public class ElasticsearchRest7Test {
@RegisterExtension
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

package io.opentelemetry.javaagent.instrumentation.elasticsearch.rest;

import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorUtil.internalSet;

import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
Expand All @@ -13,8 +15,6 @@
import io.opentelemetry.instrumentation.api.instrumenter.url.internal.UrlAttributes;
import io.opentelemetry.instrumentation.api.internal.SemconvStability;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import org.elasticsearch.client.Response;
import javax.annotation.Nullable;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Collections;
Expand All @@ -23,8 +23,8 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorUtil.internalSet;
import javax.annotation.Nullable;
import org.elasticsearch.client.Response;

public class ElasticsearchClientAttributeExtractor
implements AttributesExtractor<ElasticsearchRestRequest, Response> {
Expand All @@ -40,7 +40,8 @@ private static void setServerAttributes(AttributesBuilder attributes, Response r
}
if (SemconvStability.emitOldHttpSemconv()) {
internalSet(attributes, SemanticAttributes.NET_PEER_NAME, hostAddress.getHostAddress());
internalSet(attributes, SemanticAttributes.NET_PEER_PORT, (long) response.getHost().getPort());
internalSet(
attributes, SemanticAttributes.NET_PEER_PORT, (long) response.getHost().getPort());
}
}
}
Expand Down Expand Up @@ -83,10 +84,10 @@ public void onEnd(
/**
* Identifies the corresponding URL route by matching the actual URL path against valid URL routes
* for that corresponding endpoint definition.
* <p>
* Once the correct URL route is found, this method retrieves the URL path parameters from the URL
* path by using the corresponding URL route regex with embedded named capture groups for the URL
* path parameters.
*
* <p>Once the correct URL route is found, this method retrieves the URL path parameters from the
* URL path by using the corresponding URL route regex with embedded named capture groups for the
* URL path parameters.
*/
private void setPathPartsAttributes(
AttributesBuilder attributes, ElasticsearchRestRequest request) {
Expand Down Expand Up @@ -125,8 +126,8 @@ private void setPathPartsAttributes(
/**
* For a given route creates, compiles and caches a regular expression pattern and retrieves a set
* of pathPartNames (names of the URL path parameters).
* <p>
* The regex pattern is later being used to match against a URL path to retrieve the URL path
*
* <p>The regex pattern is later being used to match against a URL path to retrieve the URL path
* parameters for that route pattern using named regex capture groups.
*
* @param route The route to create the regex pattern for.
Expand Down

0 comments on commit befc456

Please sign in to comment.