mirror of https://github.com/grpc/grpc-java.git
Change the gRPC o11y logName when sending logs to GCP. (#9145)
* Change the gRPC o11y logName when sending logs to GCP.
This commit is contained in:
parent
ecb2210cc1
commit
56e28bc9fa
|
|
@ -47,7 +47,8 @@ public class GcpLogSink implements Sink {
|
||||||
|
|
||||||
// TODO(DNVindhya): Make cloud logging service a configurable value
|
// TODO(DNVindhya): Make cloud logging service a configurable value
|
||||||
private static final String SERVICE_TO_EXCLUDE = "google.logging.v2.LoggingServiceV2";
|
private static final String SERVICE_TO_EXCLUDE = "google.logging.v2.LoggingServiceV2";
|
||||||
private static final String DEFAULT_LOG_NAME = "grpc";
|
private static final String DEFAULT_LOG_NAME =
|
||||||
|
"microservices.googleapis.com%2Fobservability%2Fgrpc";
|
||||||
private static final String K8S_MONITORED_RESOURCE_TYPE = "k8s_container";
|
private static final String K8S_MONITORED_RESOURCE_TYPE = "k8s_container";
|
||||||
private static final Set<String> kubernetesResourceLabelSet
|
private static final Set<String> kubernetesResourceLabelSet
|
||||||
= ImmutableSet.of("project_id", "location", "cluster_name", "namespace_name",
|
= ImmutableSet.of("project_id", "location", "cluster_name", "namespace_name",
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,9 @@ public class GcpLogSinkTest {
|
||||||
private static final Map<String, String> customTags = ImmutableMap.of("KEY1", "Value1",
|
private static final Map<String, String> customTags = ImmutableMap.of("KEY1", "Value1",
|
||||||
"KEY2", "VALUE2");
|
"KEY2", "VALUE2");
|
||||||
private static final long flushLimit = 10L;
|
private static final long flushLimit = 10L;
|
||||||
|
// gRPC is expected to alway use this log name when reporting to GCP cloud logging.
|
||||||
|
private static final String expectedLogName =
|
||||||
|
"microservices.googleapis.com%2Fobservability%2Fgrpc";
|
||||||
private final long seqId = 1;
|
private final long seqId = 1;
|
||||||
private final String destProjectName = "PROJECT";
|
private final String destProjectName = "PROJECT";
|
||||||
private final String serviceName = "service";
|
private final String serviceName = "service";
|
||||||
|
|
@ -122,6 +125,7 @@ public class GcpLogSinkTest {
|
||||||
LogEntry entry = it.next();
|
LogEntry entry = it.next();
|
||||||
System.out.println(entry);
|
System.out.println(entry);
|
||||||
assertThat(entry.getPayload().getData()).isEqualTo(expectedStructLogProto);
|
assertThat(entry.getPayload().getData()).isEqualTo(expectedStructLogProto);
|
||||||
|
assertThat(entry.getLogName()).isEqualTo(expectedLogName);
|
||||||
}
|
}
|
||||||
verifyNoMoreInteractions(mockLogging);
|
verifyNoMoreInteractions(mockLogging);
|
||||||
}
|
}
|
||||||
|
|
@ -143,6 +147,7 @@ public class GcpLogSinkTest {
|
||||||
assertThat(entry.getResource()).isEqualTo(expectedMonitoredResource);
|
assertThat(entry.getResource()).isEqualTo(expectedMonitoredResource);
|
||||||
assertThat(entry.getLabels()).isEqualTo(customTags);
|
assertThat(entry.getLabels()).isEqualTo(customTags);
|
||||||
assertThat(entry.getPayload().getData()).isEqualTo(expectedStructLogProto);
|
assertThat(entry.getPayload().getData()).isEqualTo(expectedStructLogProto);
|
||||||
|
assertThat(entry.getLogName()).isEqualTo(expectedLogName);
|
||||||
}
|
}
|
||||||
verifyNoMoreInteractions(mockLogging);
|
verifyNoMoreInteractions(mockLogging);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue