scwhittle commented on code in PR #39625:
URL: https://github.com/apache/beam/pull/39625#discussion_r3749830731
##########
runners/google-cloud-dataflow-java/worker/src/test/java/org/apache/beam/runners/dataflow/worker/logging/DataflowWorkerLoggingHandlerTest.java:
##########
@@ -369,7 +391,42 @@ public void testWithCustomDataEnabledWithMdc() throws
IOException {
+
"\"message\":\"test.message\",\"thread\":\"2\",\"logger\":\"LoggerName\","
+ "\"custom_data\":{\"key1\":\"cool
value\",\"key2\":\"another\"}}"
+ System.lineSeparator(),
- createJson(createLogRecord(), null, true));
+ createJson(createLogRecord(), null, true, null));
+ }
+ }
+
+ @Test
+ public void testWithOpenTelemetryTrace() throws IOException {
+ SdkTracerProvider tracerProvider =
+ SdkTracerProvider.builder()
+
.addSpanProcessor(BatchSpanProcessor.builder(InMemorySpanExporter.create()).build())
+ .build();
+
+ // 2. Build the OpenTelemetry instance
+ OpenTelemetry openTelemetry =
+ OpenTelemetrySdk.builder()
+ .setTracerProvider(tracerProvider)
+ .build(); // Automatically calls GlobalOpenTelemetry.set()
+ Tracer tracer = openTelemetry.getTracer("foo");
+ Span span = tracer.spanBuilder("test").startSpan();
+ try (Scope scope = span.makeCurrent()) {
+ SpanContext spanContext = Span.current().getSpanContext();
Review Comment:
if spanContext is not sampled, the below assertEquals will fail since we
won't have trace_sampled entry
can you have the test handle both or otherwise make sure it is always
sampled?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]