in pkg/inst-api-semconv/instrumenter/net/network_attrs_extractor.go [34:69]
func (i *NetworkAttrsExtractor[REQUEST, RESPONSE, GETTER]) OnEnd(attributes []attribute.KeyValue, context context.Context, request REQUEST, response RESPONSE, err error) ([]attribute.KeyValue, context.Context) {
attributes = append(attributes, attribute.KeyValue{
Key: semconv.NetworkTransportKey,
Value: attribute.StringValue(i.Getter.GetNetworkTransport(request, response)),
}, attribute.KeyValue{
Key: semconv.NetworkTypeKey,
Value: attribute.StringValue(strings.ToLower(i.Getter.GetNetworkType(request, response))),
}, attribute.KeyValue{
Key: semconv.NetworkProtocolNameKey,
Value: attribute.StringValue(strings.ToLower(i.Getter.GetNetworkProtocolName(request, response))),
}, attribute.KeyValue{
Key: semconv.NetworkProtocolVersionKey,
Value: attribute.StringValue(strings.ToLower(i.Getter.GetNetworkProtocolVersion(request, response))),
}, attribute.KeyValue{
Key: semconv.NetworkLocalAddressKey,
Value: attribute.StringValue(i.Getter.GetNetworkLocalInetAddress(request, response)),
}, attribute.KeyValue{
Key: semconv.NetworkPeerAddressKey,
Value: attribute.StringValue(i.Getter.GetNetworkPeerInetAddress(request, response)),
})
localPort := i.Getter.GetNetworkLocalPort(request, response)
if localPort > 0 {
attributes = append(attributes, attribute.KeyValue{
Key: semconv.NetworkLocalPortKey,
Value: attribute.IntValue(localPort),
})
}
peerPort := i.Getter.GetNetworkPeerPort(request, response)
if peerPort > 0 {
attributes = append(attributes, attribute.KeyValue{
Key: semconv.NetworkPeerPortKey,
Value: attribute.IntValue(peerPort),
})
}
return attributes, context
}