Source:
public void startTracingSpan() { String openCensusSpanKey = "opencensus-span"; Context traceContext = new Context(openCensusSpanKey, "<user-current-span>"); Context updatedContext = tracer.start("azure.keyvault.secrets/setsecret", traceContext); System.out.printf("Span returned in the context object: %s%n", updatedContext.getData(openCensusSpanKey).get()); END: com.azure.core.util.tracing.start#string-context END String hostNameKey = "hostname"; String entityPathKey = "entity-path"; Context sendContext = new Context(openCensusSpanKey, "<user-current-span>") .addData(entityPathKey, "entity-path").addData(hostNameKey, "hostname"); END Context updatedSendContext = tracer.start("azure.eventhubs.send", sendContext, ProcessKind.SEND); System.out.printf("Span returned in the context object: %s%n", updatedSendContext.getData(openCensusSpanKey).get()); END: com.azure.core.util.tracing.start#string-context-processKind-SEND String diagnosticIdKey = "diagnostic-id"; Context updatedReceiveContext = tracer.start("azure.eventhubs.receive", traceContext, ProcessKind.RECEIVE); System.out.printf("Diagnostic Id: %s%n", updatedReceiveContext.getData(diagnosticIdKey).get().toString()); END: com.azure.core.util.tracing.start#string-context-processKind-RECEIVE String spanImplContext = "span-context"; Context processContext = new Context(openCensusSpanKey, "<user-current-span>") .addData(spanImplContext, "<user-current-span-context>"); Context updatedProcessContext = tracer.start("azure.eventhubs.process", processContext, ProcessKind.PROCESS); System.out.printf("Scope: %s%n", updatedProcessContext.getData("scope").get()); END: com.azure.core.util.tracing.start#string-context-processKind-PROCESS }

Target:
public void startTracingSpan() { Context traceContext = new Context(PARENT_SPAN_KEY, "<user-current-span>"); Context updatedContext = tracer.start("azure.keyvault.secrets/setsecret", traceContext); System.out.printf("Span returned in the context object: %s%n", updatedContext.getData(PARENT_SPAN_KEY).get()); END: com.azure.core.util.tracing.start#string-context END Context sendContext = new Context(PARENT_SPAN_KEY, "<user-current-span>") .addData(ENTITY_PATH_KEY, "entity-path").addData(HOST_NAME_KEY, "hostname"); END Context updatedSendContext = tracer.start("azure.eventhubs.send", sendContext, ProcessKind.SEND); System.out.printf("Span returned in the context object: %s%n", updatedSendContext.getData(PARENT_SPAN_KEY).get()); END: com.azure.core.util.tracing.start#string-context-processKind-SEND String diagnosticIdKey = "diagnostic-id"; Context updatedReceiveContext = tracer.start("azure.eventhubs.receive", traceContext, ProcessKind.RECEIVE); System.out.printf("Diagnostic Id: %s%n", updatedReceiveContext.getData(diagnosticIdKey).get().toString()); END: com.azure.core.util.tracing.start#string-context-processKind-RECEIVE String spanImplContext = "span-context"; Context processContext = new Context(PARENT_SPAN_KEY, "<user-current-span>") .addData(spanImplContext, "<user-current-span-context>"); Context updatedProcessContext = tracer.start("azure.eventhubs.process", processContext, ProcessKind.PROCESS); System.out.printf("Scope: %s%n", updatedProcessContext.getData("scope").get()); END: com.azure.core.util.tracing.start#string-context-processKind-PROCESS }