[otelgrpc] Emit attributes identifying host endpoint #6608
Labels
area: instrumentation
Related to an instrumentation package
enhancement
New feature or request
instrumentation: otelgrpc
Problem Statement
When used with a gRPC server,
otelgrpc
does not seem to emit span/metric attributes identifying the endpoint address or port number. This is problematic for its use in the OTLP receiver, as we want to make sure users can identify which receiver instance emitted a span/metric when multiple gRPC endpoints are configured, and the last resort of comparing the port number with the receiver config is not currently possible.Under the 1.17.0 semantic convention (for spans / for metrics), which seems to be the one that is currently implemented, this would correspond to the
net.sock.host.addr
andnet.sock.host.port
attributes.Note that these attributes are "Recommended" under said convention, but the corresponding
server.address
andserver.port
attributes in the latest 1.29.0 semantic convention (for spans / for metrics) are actually "Required" for spans, so they would have to be implemented as part of a convention version upgrade.Proposed Solution
Emit
net.sock.host.addr
andnet.sock.host.port
attributes. If I'm not mistaken, I believe this information can be obtained from theLocalAddr
field in theConnTagInfo
andInHeader
structs received in the stats handler.Alternatives
An alternative for users would be to manually setup these attributes by passing
WithSpanAttributes
/WithMetricAttributes
options toNewServerHandler
.Prior Art
otelhttp
provides the similarnet.host.name
andnet.host.port
, although those seem to be derived from the HTTPHost
header.The text was updated successfully, but these errors were encountered: