Skip to content

Commit

Permalink
Reverts back to remove inetaddresss
Browse files Browse the repository at this point in the history
  • Loading branch information
anuragagarwal561994 committed Jan 28, 2023
1 parent 7760022 commit a106ca4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,6 @@ public static Integer getPeerPort(URI uri) {
return uri == null ? null : uri.getPort();
}

public static InetSocketAddress getPeerSocketAddress(HttpHost target) {
if (target == null) {
return null;
}
InetAddress inetAddress = target.getAddress();
return inetAddress == null ? null : new InetSocketAddress(inetAddress, target.getPort());
}

@Nullable
private static URI getCalculatedUri(HttpHost httpHost, URI uri) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import io.opentelemetry.context.Context;
import io.opentelemetry.javaagent.instrumentation.apachehttpclient.commons.BytesTransferMetrics;
import io.opentelemetry.javaagent.instrumentation.apachehttpclient.commons.OtelHttpRequest;
import java.net.InetSocketAddress;
import java.net.URI;
import java.util.List;
import javax.annotation.Nullable;
Expand All @@ -21,27 +20,24 @@
public final class ApacheHttpClientRequest implements OtelHttpRequest {
private final Context parentContext;
@Nullable private final URI uri;
@Nullable private final HttpHost target;
private final HttpRequest httpRequest;

private ApacheHttpClientRequest(
Context parentContext, URI uri, HttpHost target, HttpRequest httpRequest) {
private ApacheHttpClientRequest(Context parentContext, URI uri, HttpRequest httpRequest) {
this.parentContext = parentContext;
this.uri = uri;
this.httpRequest = httpRequest;
this.target = target;
}

public ApacheHttpClientRequest(Context parentContext, HttpHost target, HttpRequest httpRequest) {
this(parentContext, getUri(target, httpRequest), target, httpRequest);
this(parentContext, getUri(target, httpRequest), httpRequest);
}

public ApacheHttpClientRequest(Context parentContext, HttpUriRequest httpRequest) {
this(parentContext, httpRequest.getURI(), null, httpRequest);
this(parentContext, httpRequest.getURI(), httpRequest);
}

public ApacheHttpClientRequest withHttpRequest(HttpRequest httpRequest) {
return new ApacheHttpClientRequest(parentContext, uri, target, httpRequest);
return new ApacheHttpClientRequest(parentContext, uri, httpRequest);
}

@Override
Expand Down Expand Up @@ -74,11 +70,6 @@ public Integer getPeerPort() {
return ApacheHttpClientAttributesHelper.getPeerPort(uri);
}

@Nullable
public InetSocketAddress getPeerSocketAddress() {
return ApacheHttpClientAttributesHelper.getPeerSocketAddress(target);
}

@Override
public List<String> getHeader(String name) {
return ApacheHttpClientAttributesHelper.getHeader(httpRequest, name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@

package io.opentelemetry.javaagent.instrumentation.apachehttpclient.commons;

import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesGetter;
import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import java.net.InetSocketAddress;
import javax.annotation.Nullable;

public final class ApacheHttpClientNetAttributesGetter extends
InetSocketAddressNetClientAttributesGetter<OtelHttpRequest, OtelHttpResponse> {
public final class ApacheHttpClientNetAttributesGetter implements
NetClientAttributesGetter<OtelHttpRequest, OtelHttpResponse> {
@Override
public String getTransport(OtelHttpRequest request, @Nullable OtelHttpResponse response) {
return SemanticAttributes.NetTransportValues.IP_TCP;
Expand All @@ -27,11 +26,4 @@ public String getPeerName(OtelHttpRequest request) {
public Integer getPeerPort(OtelHttpRequest request) {
return request.getPeerPort();
}

@Nullable
@Override
public InetSocketAddress getPeerSocketAddress(
OtelHttpRequest request, @Nullable OtelHttpResponse response) {
return request.getPeerSocketAddress();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ public interface OtelHttpRequest {

Integer getPeerPort();

InetSocketAddress getPeerSocketAddress();

String getMethod();

String getUrl();
Expand Down

0 comments on commit a106ca4

Please sign in to comment.