Skip to content

Commit bc870ba

Browse files
authored
Remove extra space from kubernetes client span name (#8540)
1 parent e6183dc commit bc870ba

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

instrumentation/kubernetes-client-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/kubernetesclient/KubernetesRequestDigest.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,14 @@ public String toString() {
106106
targetResourceName = resourceMeta.getResource() + "/" + resourceMeta.getSubResource();
107107
}
108108

109-
return verb.value() + ' ' + groupVersion + ' ' + targetResourceName;
109+
StringBuilder result = new StringBuilder(verb.value());
110+
if (!groupVersion.isEmpty()) {
111+
result.append(" ").append(groupVersion);
112+
}
113+
if (!targetResourceName.isEmpty()) {
114+
result.append(" ").append(targetResourceName);
115+
}
116+
return result.toString();
110117
}
111118

112119
private static boolean isNullOrEmpty(String s) {

instrumentation/kubernetes-client-7.0/javaagent/src/test/groovy/KubernetesClientTest.groovy

+4-4
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class KubernetesClientTest extends AgentInstrumentationSpecification {
6868
kind SpanKind.INTERNAL
6969
hasNoParent()
7070
}
71-
apiClientSpan(it, 1, "get pods/proxy", "${server.httpUri()}/api/v1/namespaces/namespace/pods/name/proxy?path=path", 200)
71+
apiClientSpan(it, 1, "get pods/proxy", "${server.httpUri()}/api/v1/namespaces/namespace/pods/name/proxy?path=path", 200)
7272
}
7373
}
7474
}
@@ -95,7 +95,7 @@ class KubernetesClientTest extends AgentInstrumentationSpecification {
9595
status ERROR
9696
errorEvent(exception.class, exception.message)
9797
}
98-
apiClientSpan(it, 1, "get pods/proxy", "${server.httpUri()}/api/v1/namespaces/namespace/pods/name/proxy?path=path", 451, exception)
98+
apiClientSpan(it, 1, "get pods/proxy", "${server.httpUri()}/api/v1/namespaces/namespace/pods/name/proxy?path=path", 451, exception)
9999
}
100100
}
101101
}
@@ -131,7 +131,7 @@ class KubernetesClientTest extends AgentInstrumentationSpecification {
131131
kind SpanKind.INTERNAL
132132
hasNoParent()
133133
}
134-
apiClientSpan(it, 1, "get pods/proxy", "${server.httpUri()}/api/v1/namespaces/namespace/pods/name/proxy?path=path", 200)
134+
apiClientSpan(it, 1, "get pods/proxy", "${server.httpUri()}/api/v1/namespaces/namespace/pods/name/proxy?path=path", 200)
135135
span(2) {
136136
name "callback"
137137
kind SpanKind.INTERNAL
@@ -172,7 +172,7 @@ class KubernetesClientTest extends AgentInstrumentationSpecification {
172172
kind SpanKind.INTERNAL
173173
hasNoParent()
174174
}
175-
apiClientSpan(it, 1, "get pods/proxy", "${server.httpUri()}/api/v1/namespaces/namespace/pods/name/proxy?path=path", 451, exception.get())
175+
apiClientSpan(it, 1, "get pods/proxy", "${server.httpUri()}/api/v1/namespaces/namespace/pods/name/proxy?path=path", 451, exception.get())
176176
span(2) {
177177
name "callback"
178178
kind SpanKind.INTERNAL

0 commit comments

Comments
 (0)