zipkin-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [incubator-zipkin-brave] llinder commented on a change in pull request #904: Messaging adapter
Date Mon, 20 May 2019 10:21:32 GMT
llinder commented on a change in pull request #904: Messaging adapter
URL: https://github.com/apache/incubator-zipkin-brave/pull/904#discussion_r285522579
 
 

 ##########
 File path: instrumentation/messaging/src/main/java/brave/messaging/MessagingParser.java
 ##########
 @@ -0,0 +1,43 @@
+package brave.messaging;
+
+import brave.SpanCustomizer;
+import brave.propagation.TraceContext;
+import brave.propagation.TraceContextOrSamplingFlags;
+
+public class MessagingParser {
+
+  public <Chan, Msg> void message(ChannelAdapter<Chan> channelAdapter,
+      MessageAdapter<Msg> messageAdapter,
+      Chan channel, Msg message, SpanCustomizer customizer) {
+    customizer.name(messageAdapter.operation(message));
+    channel(channelAdapter, channel, customizer);
+    identifier(messageAdapter, message, customizer);
+  }
+
+  public <Chan> void channel(ChannelAdapter<Chan> adapter, Chan chan,
+      SpanCustomizer customizer) {
+    String channel = adapter.channel(chan);
+    if (chan != null) customizer.tag(adapter.channelTagKey(chan), channel);
+  }
+
+  public <Msg> void identifier(MessageAdapter<Msg> adapter, Msg message,
+      SpanCustomizer customizer) {
+    String identifier = adapter.identifier(message);
+    if (identifier != null) {
+      customizer.tag(adapter.identifierTagKey(), adapter.identifier(message));
 
 Review comment:
   Small nit but I think this could just be `customizer.tag(adapter.identifierTagKey(), identifier);`.
 Also should we do a null and empty string check on `adapter.identifierTagKey()` just to ensure
a bad adapter doesn't cause issues?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@zipkin.apache.org
For additional commands, e-mail: dev-help@zipkin.apache.org


Mime
View raw message