|
9 | 9 | import com.azure.core.amqp.implementation.TracerProvider; |
10 | 10 | import com.azure.core.util.Context; |
11 | 11 | import com.azure.core.util.CoreUtils; |
12 | | -import com.azure.core.util.logging.ClientLogger; |
13 | 12 | import com.azure.core.util.tracing.ProcessKind; |
14 | 13 | import com.azure.messaging.servicebus.ServiceBusMessage; |
15 | | -import com.azure.messaging.servicebus.ServiceBusReceivedMessage; |
16 | 14 | import com.azure.messaging.servicebus.ServiceBusTransactionContext; |
17 | 15 | import org.apache.qpid.proton.amqp.Binary; |
18 | 16 | import org.apache.qpid.proton.amqp.Symbol; |
|
25 | 23 | import org.apache.qpid.proton.amqp.transport.ErrorCondition; |
26 | 24 | import reactor.core.publisher.Signal; |
27 | 25 |
|
28 | | -import java.io.Closeable; |
29 | | -import java.io.IOException; |
30 | 26 | import java.nio.ByteBuffer; |
31 | 27 | import java.time.Duration; |
32 | 28 | import java.time.Instant; |
33 | 29 | import java.time.OffsetDateTime; |
34 | 30 | import java.time.ZoneOffset; |
35 | 31 | import java.util.HashMap; |
36 | | -import java.util.Locale; |
37 | 32 | import java.util.Map; |
38 | 33 | import java.util.Optional; |
39 | 34 | import java.util.UUID; |
|
42 | 37 | import static com.azure.core.util.tracing.Tracer.DIAGNOSTIC_ID_KEY; |
43 | 38 | import static com.azure.core.util.tracing.Tracer.ENTITY_PATH_KEY; |
44 | 39 | import static com.azure.core.util.tracing.Tracer.HOST_NAME_KEY; |
45 | | -import static com.azure.core.util.tracing.Tracer.MESSAGE_ENQUEUED_TIME; |
46 | | -import static com.azure.core.util.tracing.Tracer.SCOPE_KEY; |
47 | 40 | import static com.azure.core.util.tracing.Tracer.SPAN_CONTEXT_KEY; |
48 | 41 | import static com.azure.messaging.servicebus.implementation.ServiceBusConstants.AZ_TRACING_SERVICE_NAME; |
49 | 42 | import static com.azure.messaging.servicebus.implementation.ServiceBusConstants.AZ_TRACING_NAMESPACE_VALUE; |
@@ -329,51 +322,4 @@ public static ServiceBusMessage traceMessageSpan(ServiceBusMessage serviceBusMes |
329 | 322 | } |
330 | 323 | return serviceBusMessage; |
331 | 324 | } |
332 | | - |
333 | | - /* |
334 | | - * Starts a new process tracing span and attaches the returned context to the ServiceBusReceivedMessage object for |
335 | | - * users. |
336 | | - */ |
337 | | - public static Context startProcessTracingSpan(ServiceBusReceivedMessage receivedMessage, |
338 | | - String hostname, String entityPath, TracerProvider tracerProvider, ProcessKind processKind) { |
339 | | - Object diagnosticId = receivedMessage.getApplicationProperties().get(DIAGNOSTIC_ID_KEY); |
340 | | - if (diagnosticId == null || !tracerProvider.isEnabled()) { |
341 | | - return Context.NONE; |
342 | | - } |
343 | | - |
344 | | - Context spanContext = tracerProvider.extractContext(diagnosticId.toString(), Context.NONE) |
345 | | - .addData(ENTITY_PATH_KEY, entityPath) |
346 | | - .addData(HOST_NAME_KEY, hostname) |
347 | | - .addData(AZ_TRACING_NAMESPACE_KEY, AZ_TRACING_NAMESPACE_VALUE); |
348 | | - spanContext = receivedMessage.getEnqueuedTime() == null |
349 | | - ? spanContext |
350 | | - : spanContext.addData(MESSAGE_ENQUEUED_TIME, receivedMessage.getEnqueuedTime().toEpochSecond()); |
351 | | - return tracerProvider.startSpan(AZ_TRACING_SERVICE_NAME, spanContext, processKind); |
352 | | - } |
353 | | - |
354 | | - /* |
355 | | - * Ends the process tracing span and the scope of that span. |
356 | | - */ |
357 | | - public static void endProcessTracingSpan(Context processSpanContext, Signal<Void> signal, |
358 | | - TracerProvider tracerProvider, ClientLogger logger) { |
359 | | - if (processSpanContext != null) { |
360 | | - Optional<Object> spanScope = processSpanContext.getData(SCOPE_KEY); |
361 | | - // Disposes of the scope when the trace span closes. |
362 | | - if (tracerProvider.isEnabled() && spanScope.isPresent()) { |
363 | | - if (spanScope.get() instanceof Closeable) { |
364 | | - Closeable close = (Closeable) spanScope.get(); |
365 | | - try { |
366 | | - close.close(); |
367 | | - tracerProvider.endSpan(processSpanContext, signal); |
368 | | - } catch (IOException ioException) { |
369 | | - logger.error(Messages.MESSAGE_PROCESSOR_RUN_END, ioException); |
370 | | - } |
371 | | - |
372 | | - } else { |
373 | | - logger.warning(String.format(Locale.US, |
374 | | - Messages.PROCESS_SPAN_SCOPE_TYPE_ERROR, spanScope.getClass())); |
375 | | - } |
376 | | - } |
377 | | - } |
378 | | - } |
379 | 325 | } |
0 commit comments