Skip to content

Commit

Permalink
Remove extra space from kubernetes client span name (#8540)
Browse files Browse the repository at this point in the history
  • Loading branch information
laurit authored May 22, 2023
1 parent e6183dc commit bc870ba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,14 @@ public String toString() {
targetResourceName = resourceMeta.getResource() + "/" + resourceMeta.getSubResource();
}

return verb.value() + ' ' + groupVersion + ' ' + targetResourceName;
StringBuilder result = new StringBuilder(verb.value());
if (!groupVersion.isEmpty()) {
result.append(" ").append(groupVersion);
}
if (!targetResourceName.isEmpty()) {
result.append(" ").append(targetResourceName);
}
return result.toString();
}

private static boolean isNullOrEmpty(String s) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class KubernetesClientTest extends AgentInstrumentationSpecification {
kind SpanKind.INTERNAL
hasNoParent()
}
apiClientSpan(it, 1, "get pods/proxy", "${server.httpUri()}/api/v1/namespaces/namespace/pods/name/proxy?path=path", 200)
apiClientSpan(it, 1, "get pods/proxy", "${server.httpUri()}/api/v1/namespaces/namespace/pods/name/proxy?path=path", 200)
}
}
}
Expand All @@ -95,7 +95,7 @@ class KubernetesClientTest extends AgentInstrumentationSpecification {
status ERROR
errorEvent(exception.class, exception.message)
}
apiClientSpan(it, 1, "get pods/proxy", "${server.httpUri()}/api/v1/namespaces/namespace/pods/name/proxy?path=path", 451, exception)
apiClientSpan(it, 1, "get pods/proxy", "${server.httpUri()}/api/v1/namespaces/namespace/pods/name/proxy?path=path", 451, exception)
}
}
}
Expand Down Expand Up @@ -131,7 +131,7 @@ class KubernetesClientTest extends AgentInstrumentationSpecification {
kind SpanKind.INTERNAL
hasNoParent()
}
apiClientSpan(it, 1, "get pods/proxy", "${server.httpUri()}/api/v1/namespaces/namespace/pods/name/proxy?path=path", 200)
apiClientSpan(it, 1, "get pods/proxy", "${server.httpUri()}/api/v1/namespaces/namespace/pods/name/proxy?path=path", 200)
span(2) {
name "callback"
kind SpanKind.INTERNAL
Expand Down Expand Up @@ -172,7 +172,7 @@ class KubernetesClientTest extends AgentInstrumentationSpecification {
kind SpanKind.INTERNAL
hasNoParent()
}
apiClientSpan(it, 1, "get pods/proxy", "${server.httpUri()}/api/v1/namespaces/namespace/pods/name/proxy?path=path", 451, exception.get())
apiClientSpan(it, 1, "get pods/proxy", "${server.httpUri()}/api/v1/namespaces/namespace/pods/name/proxy?path=path", 451, exception.get())
span(2) {
name "callback"
kind SpanKind.INTERNAL
Expand Down

0 comments on commit bc870ba

Please sign in to comment.