Skip to content

Commit

Permalink
add namespace to server and peer name across namespaces in name resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
esara committed Oct 27, 2024
1 parent 750eab0 commit 0633e1c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 6 additions & 0 deletions pkg/transform/name_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

Expand Down
12 changes: 6 additions & 6 deletions pkg/transform/name_resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 0633e1c

Please sign in to comment.