mirror of https://github.com/grpc/grpc-java.git
gcp-observability: trim the string to remove newline for hostname and namespace name from files (#9043)
This commit is contained in:
parent
c53c3ad01b
commit
fda3a2d6ff
|
|
@ -71,10 +71,10 @@ final class GlobalLoggingTags {
|
|||
String hostnameFile, String cgroupFile) {
|
||||
// namespace name: contents of file /var/run/secrets/kubernetes.io/serviceaccount/namespace
|
||||
populateFromFileContents(customTags, "namespace_name",
|
||||
namespaceFile, (value) -> value);
|
||||
namespaceFile, (value) -> value.trim());
|
||||
|
||||
// pod_name: hostname i.e. contents of /etc/hostname
|
||||
populateFromFileContents(customTags, "pod_name", hostnameFile, (value) -> value);
|
||||
populateFromFileContents(customTags, "pod_name", hostnameFile, (value) -> value.trim());
|
||||
|
||||
// container_id: parsed from /proc/self/cgroup . Note: only works for Linux-based containers
|
||||
populateFromFileContents(customTags, "container_id", cgroupFile,
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ public class GlobalLoggingTagsTest {
|
|||
File cgroupFile = cgroupFolder.newFile();
|
||||
|
||||
Files.write("test-namespace1".getBytes(StandardCharsets.UTF_8), namespaceFile);
|
||||
Files.write("test-hostname2".getBytes(StandardCharsets.UTF_8), hostnameFile);
|
||||
Files.write("test-hostname2\n".getBytes(StandardCharsets.UTF_8), hostnameFile);
|
||||
Files.write(FILE_CONTENTS.getBytes(StandardCharsets.UTF_8), cgroupFile);
|
||||
|
||||
ImmutableMap.Builder<String, String> customTags = ImmutableMap.builder();
|
||||
|
|
|
|||
Loading…
Reference in New Issue