Skip to content

Commit 591cdf5

Browse files
authored
Move get attribute inside condition where used (#12604)
1 parent 0e099b2 commit 591cdf5

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/semconv/network/internal/InternalNetworkAttributesExtractor.java

+12-7
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,23 @@ public InternalNetworkAttributesExtractor(
3333
}
3434

3535
public void onEnd(AttributesBuilder attributes, REQUEST request, @Nullable RESPONSE response) {
36-
String protocolName = lowercase(getter.getNetworkProtocolName(request, response));
37-
String protocolVersion = lowercase(getter.getNetworkProtocolVersion(request, response));
38-
3936
if (captureProtocolAttributes) {
40-
String transport = lowercase(getter.getNetworkTransport(request, response));
41-
internalSet(attributes, NetworkAttributes.NETWORK_TRANSPORT, transport);
37+
internalSet(
38+
attributes,
39+
NetworkAttributes.NETWORK_TRANSPORT,
40+
lowercase(getter.getNetworkTransport(request, response)));
4241
internalSet(
4342
attributes,
4443
NetworkAttributes.NETWORK_TYPE,
4544
lowercase(getter.getNetworkType(request, response)));
46-
internalSet(attributes, NetworkAttributes.NETWORK_PROTOCOL_NAME, protocolName);
47-
internalSet(attributes, NetworkAttributes.NETWORK_PROTOCOL_VERSION, protocolVersion);
45+
internalSet(
46+
attributes,
47+
NetworkAttributes.NETWORK_PROTOCOL_NAME,
48+
lowercase(getter.getNetworkProtocolName(request, response)));
49+
internalSet(
50+
attributes,
51+
NetworkAttributes.NETWORK_PROTOCOL_VERSION,
52+
lowercase(getter.getNetworkProtocolVersion(request, response)));
4853
}
4954

5055
if (captureLocalSocketAttributes) {

0 commit comments

Comments
 (0)