Skip to content

Commit

Permalink
add namespace to server and peer name across namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
esara committed Oct 11, 2024
1 parent 8c3c9db commit b64c0a5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/transform/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ func (md *metadataDecorator) nodeLoop(in <-chan []request.Span, out chan<- []req
}

func (md *metadataDecorator) do(span *request.Span) {
if podInfo, ok := md.db.OwnerPodInfo(span.Pid.Namespace); ok {
var podInfo *kube.PodInfo
var ok bool
if podInfo, ok = md.db.OwnerPodInfo(span.Pid.Namespace); ok {
md.appendMetadata(span, podInfo)
} else {
// do not leave the service attributes map as nil
Expand All @@ -99,9 +101,15 @@ func (md *metadataDecorator) do(span *request.Span) {
// override the peer and host names from Kubernetes metadata, if found
if hn := md.db.HostNameForIP(span.Host); hn != "" {
span.HostName = hn
if span.OtherNamespace != "" && podInfo != nil && podInfo.Namespace != span.OtherNamespace {
span.HostName = hn + "." + span.OtherNamespace
}
}
if pn := md.db.HostNameForIP(span.Peer); pn != "" {
span.PeerName = pn
if span.OtherNamespace != "" && podInfo != nil && podInfo.Namespace != span.OtherNamespace {
span.PeerName = pn + "." + span.OtherNamespace
}
}
}

Expand Down

0 comments on commit b64c0a5

Please sign in to comment.