jojochuang commented on a change in pull request #1846: HADOOP-15566. Support
Opentracing
URL: https://github.com/apache/hadoop/pull/1846#discussion_r382858893
##########
File path:
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/tracing/TraceUtils.java
##########
@@ -72,4 +97,71 @@ private String getInternal(String key) {
}
};
}
+
+ public static Tracer createAndRegisterTracer(String name) {
+ if (!GlobalTracer.isRegistered()) {
+ io.jaegertracing.Configuration config =
+ io.jaegertracing.Configuration.fromEnv(name);
+ Tracer tracer = config.getTracerBuilder().build();
+ GlobalTracer.register(tracer);
+ }
+
+ return GlobalTracer.get();
+ }
+
+ public static SpanContext byteStringToSpanContext(ByteString byteString) {
+ if (byteString == null || byteString.isEmpty()) {
+ LOG.debug("The provided serialized context was null or empty");
+ return null;
+ }
+
+ SpanContext context = null;
+ ByteArrayInputStream stream =
+ new ByteArrayInputStream(byteString.toByteArray());
+
+ try {
+ ObjectInputStream objStream = new ObjectInputStream(stream);
+ Map<String, String> carrier =
+ (Map<String, String>) objStream.readObject();
+
+ context = GlobalTracer.get().extract(Format.Builtin.TEXT_MAP,
+ new TextMapExtractAdapter(carrier));
+ } catch (Exception e) {
+ LOG.warn("Could not deserialize context {}", e);
Review comment:
did you forget to log variable byteString?
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]