From 0633e1cfc66976ccddc189a8a71c7ec7a27c1ed2 Mon Sep 17 00:00:00 2001 From: esara Date: Thu, 10 Oct 2024 23:34:38 -0400 Subject: [PATCH] add namespace to server and peer name across namespaces in name resolver --- pkg/transform/name_resolver.go | 6 ++++++ pkg/transform/name_resolver_test.go | 12 ++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/pkg/transform/name_resolver.go b/pkg/transform/name_resolver.go index 1fdfb479b..64495c3d8 100644 --- a/pkg/transform/name_resolver.go +++ b/pkg/transform/name_resolver.go @@ -125,9 +125,15 @@ func (nr *NameResolver) resolveNames(span *request.Span) { // in a previous stage (e.g. Kubernetes decorator) if pn != "" { span.PeerName = pn + if span.OtherNamespace != "" { + span.PeerName = pn + "." + span.OtherNamespace + } } if hn != "" { span.HostName = hn + if span.OtherNamespace != "" { + span.HostName = hn + "." + span.OtherNamespace + } } } diff --git a/pkg/transform/name_resolver_test.go b/pkg/transform/name_resolver_test.go index 1fcb3bae2..f58b53b4c 100644 --- a/pkg/transform/name_resolver_test.go +++ b/pkg/transform/name_resolver_test.go @@ -90,9 +90,9 @@ func TestResolvePodsFromK8s(t *testing.T) { nr.resolveNames(&clientSpan) - assert.Equal(t, "pod1", clientSpan.PeerName) + assert.Equal(t, "pod1.something", clientSpan.PeerName) assert.Equal(t, "", clientSpan.ServiceID.Namespace) - assert.Equal(t, "pod2", clientSpan.HostName) + assert.Equal(t, "pod2.something", clientSpan.HostName) assert.Equal(t, "something", clientSpan.OtherNamespace) nr.resolveNames(&serverSpan) @@ -161,9 +161,9 @@ func TestResolveServiceFromK8s(t *testing.T) { nr.resolveNames(&clientSpan) - assert.Equal(t, "pod1", clientSpan.PeerName) + assert.Equal(t, "pod1.something", clientSpan.PeerName) assert.Equal(t, "", clientSpan.ServiceID.Namespace) - assert.Equal(t, "pod2", clientSpan.HostName) + assert.Equal(t, "pod2.something", clientSpan.HostName) assert.Equal(t, "something", clientSpan.OtherNamespace) nr.resolveNames(&serverSpan) @@ -251,9 +251,9 @@ func TestResolveNodesFromK8s(t *testing.T) { nr.resolveNames(&clientSpan) - assert.Equal(t, "node1", clientSpan.PeerName) + assert.Equal(t, "node1.something", clientSpan.PeerName) assert.Equal(t, "", clientSpan.ServiceID.Namespace) - assert.Equal(t, "node2", clientSpan.HostName) + assert.Equal(t, "node2.something", clientSpan.HostName) assert.Equal(t, "something", clientSpan.OtherNamespace) nr.resolveNames(&serverSpan)