Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/propagation"
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
semconv "go.opentelemetry.io/otel/semconv/v1.26.0"
"go.opentelemetry.io/otel/trace"
)

Expand Down
23 changes: 9 additions & 14 deletions interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import (
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/metric"
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
semconv "go.opentelemetry.io/otel/semconv/v1.26.0"
"go.opentelemetry.io/otel/trace"
grpc_codes "google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
Expand Down Expand Up @@ -202,20 +202,15 @@ func peerAttr(addr string) []attribute.KeyValue {
return []attribute.KeyValue(nil)
}

var attr []attribute.KeyValue
if ip := net.ParseIP(host); ip != nil {
attr = []attribute.KeyValue{
semconv.NetSockPeerAddr(host),
semconv.NetSockPeerPort(port),
}
} else {
attr = []attribute.KeyValue{
semconv.NetPeerName(host),
semconv.NetPeerPort(port),
}
return []attribute.KeyValue{
// NOTE(thaJeztah): strictly, we should use NetworkPeerAddress for IP-addresses,
// and either "semconv.ClientAddress" + "semconv.ClientPort" / "semconv.ServerAddress" + "semconv.ServerPort"
// for hostnames. However, this code is generic and doesn't distinguish "client" vs "server".
//
// See https://opentelemetry.io/docs/specs/semconv/general/attributes/
semconv.NetworkPeerAddress(host),
semconv.NetworkPeerPort(port),
}

return attr
}

// peerFromCtx returns a peer address from a context, if one exists.
Expand Down
2 changes: 1 addition & 1 deletion internal/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
"strings"

"go.opentelemetry.io/otel/attribute"
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
semconv "go.opentelemetry.io/otel/semconv/v1.26.0"
)

// ParseFullMethod returns a span name following the OpenTelemetry semantic
Expand Down
2 changes: 1 addition & 1 deletion semconv.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ package otelttrpc

import (
"go.opentelemetry.io/otel/attribute"
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
semconv "go.opentelemetry.io/otel/semconv/v1.26.0"
)

// Semantic conventions for attribute keys for ttRPC.
Expand Down
Loading