Skip to content

Commit

Permalink
Fix server -> client reference (#5396)
Browse files Browse the repository at this point in the history
  • Loading branch information
trask authored Feb 19, 2022
1 parent 53a8b85 commit d7725d2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,33 @@

package io.opentelemetry.instrumentation.spring.web;

import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesGetter;
import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import javax.annotation.Nullable;
import org.springframework.http.HttpRequest;
import org.springframework.http.client.ClientHttpResponse;

final class SpringWebNetAttributesGetter implements NetServerAttributesGetter<HttpRequest> {
final class SpringWebNetAttributesGetter
implements NetClientAttributesGetter<HttpRequest, ClientHttpResponse> {
@Override
public String transport(HttpRequest httpRequest) {
public String transport(HttpRequest httpRequest, @Nullable ClientHttpResponse response) {
return SemanticAttributes.NetTransportValues.IP_TCP;
}

@Override
@Nullable
public String peerName(HttpRequest httpRequest) {
public String peerName(HttpRequest httpRequest, @Nullable ClientHttpResponse response) {
return httpRequest.getURI().getHost();
}

@Override
public Integer peerPort(HttpRequest httpRequest) {
public Integer peerPort(HttpRequest httpRequest, @Nullable ClientHttpResponse response) {
return httpRequest.getURI().getPort();
}

@Override
@Nullable
public String peerIp(HttpRequest httpRequest) {
public String peerIp(HttpRequest httpRequest, @Nullable ClientHttpResponse response) {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor;
import java.util.ArrayList;
import java.util.List;
import org.springframework.http.HttpRequest;
Expand Down Expand Up @@ -71,7 +71,7 @@ public SpringWebTracing build() {
.setSpanStatusExtractor(HttpSpanStatusExtractor.create(httpAttributeGetter))
.addAttributesExtractor(
HttpClientAttributesExtractor.create(httpAttributeGetter, capturedHttpHeaders))
.addAttributesExtractor(NetServerAttributesExtractor.create(netAttributesGetter))
.addAttributesExtractor(NetClientAttributesExtractor.create(netAttributesGetter))
.addAttributesExtractors(additionalExtractors)
.addRequestMetrics(HttpClientMetrics.get())
.newClientInstrumenter(HttpRequestSetter.INSTANCE);
Expand Down

0 comments on commit d7725d2

Please sign in to comment.