gemini-code-assist[bot] commented on code in PR #36962:
URL: https://github.com/apache/beam/pull/36962#discussion_r2581643544


##########
sdks/java/core/src/main/java/org/apache/beam/sdk/values/WindowedValues.java:
##########
@@ -945,13 +1042,16 @@ public WindowedValue<T> decode(InputStream inStream, 
Context context)
             b
                 ? 
elementMetadata.getDrain().equals(BeamFnApi.Elements.DrainMode.Enum.DRAINING)
                 : false;
+        otelContext = OpenTelemetryContextSerializer.read(elementMetadata);
+        // todo radek decode w3c context
+        // context = elementMetadata

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   The `// todo radek decode w3c context` comment suggests that the W3C context 
decoding might be incomplete or a placeholder. Please clarify the current state 
and future plans for this aspect of W3C context handling.



##########
sdks/java/core/src/main/java/org/apache/beam/sdk/values/WindowedValues.java:
##########
@@ -990,6 +1090,52 @@ public List<? extends Coder<?>> getComponents() {
     }
   }
 
+  public static class OpenTelemetryContextSerializer {
+
+    private static final 
TextMapSetter<BeamFnApi.Elements.ElementMetadata.Builder> SETTER =
+        (carrier, key, value) -> {
+          if (carrier == null) {
+            return;
+          }
+          if ("traceparent".equals(key)) {
+            carrier.setTraceparent(value);
+          } else if ("tracestate".equals(key)) {
+            carrier.setTracestate(value);
+          }
+        };
+
+    private static final TextMapGetter<BeamFnApi.Elements.ElementMetadata> 
GETTER =
+        new TextMapGetter<BeamFnApi.Elements.ElementMetadata>() {
+          @Override
+          public Iterable<String> keys(BeamFnApi.Elements.ElementMetadata 
carrier) {
+            // W3C Propagator knows what keys it wants, but this satisfies the 
interface
+            return Collections.emptyList();

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   The comment `// W3C Propagator knows what keys it wants, but this satisfies 
the interface` for the `keys` method in `TextMapGetter` is a bit vague. While 
`Collections.emptyList()` might satisfy the interface, it would be more robust 
to return the actual keys that the W3C propagator expects, if known, or provide 
a more explicit explanation of why `emptyList` is sufficient and correct here.



-- 
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]

Reply via email to