-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ServiceBus: fix session tracing (#39962)
* remove additional matrix * Fix session processing and disposition instrumentation * return matrix config * review suggestions
- Loading branch information
Showing
11 changed files
with
230 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 0 additions & 71 deletions
71
.../azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/FluxTraceV2.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
...essaging-servicebus/src/main/java/com/azure/messaging/servicebus/TracingFluxOperator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.messaging.servicebus; | ||
|
||
import com.azure.messaging.servicebus.implementation.instrumentation.ReceiverKind; | ||
import com.azure.messaging.servicebus.implementation.instrumentation.ServiceBusReceiverInstrumentation; | ||
import org.apache.qpid.proton.message.Message; | ||
import org.reactivestreams.Subscription; | ||
import reactor.core.CoreSubscriber; | ||
import reactor.core.publisher.BaseSubscriber; | ||
import reactor.core.publisher.Flux; | ||
import reactor.core.publisher.FluxOperator; | ||
|
||
import java.util.Objects; | ||
import java.util.function.BiConsumer; | ||
import java.util.function.Function; | ||
|
||
/** | ||
* Flux operator that traces receive and process calls | ||
*/ | ||
final class TracingFluxOperator<T> extends BaseSubscriber<T> { | ||
|
||
public static <T> Flux<T> create(Flux<T> upstream, ServiceBusReceiverInstrumentation instrumentation) { | ||
if (!instrumentation.isEnabled() && instrumentation.isAsyncReceiverInstrumentation()) { | ||
return upstream; | ||
} | ||
|
||
return new FluxOperator<T, T>(upstream) { | ||
@SuppressWarnings("unchecked") | ||
@Override | ||
public void subscribe(CoreSubscriber<? super T> actual) { | ||
Objects.requireNonNull(actual, "'actual' cannot be null."); | ||
source.subscribe(new TracingFluxOperator<T>(actual, (msg, handler) -> { | ||
if (msg instanceof Message) { | ||
instrumentation.instrumentProcess((Message) msg, ReceiverKind.ASYNC_RECEIVER, | ||
(Function<Message, Throwable>) handler); | ||
} else if (msg instanceof ServiceBusReceivedMessage) { | ||
instrumentation.instrumentProcess((ServiceBusReceivedMessage) msg, ReceiverKind.ASYNC_RECEIVER, | ||
(Function<ServiceBusReceivedMessage, Throwable>) handler); | ||
} | ||
})); | ||
} | ||
}; | ||
} | ||
|
||
private final CoreSubscriber<? super T> downstream; | ||
private final BiConsumer<T, Function<T, Throwable>> instrumentation; | ||
private TracingFluxOperator(CoreSubscriber<? super T> downstream, BiConsumer<T, Function<T, Throwable>> instrumentation) { | ||
this.downstream = downstream; | ||
this.instrumentation = instrumentation; | ||
} | ||
|
||
@Override | ||
public reactor.util.context.Context currentContext() { | ||
return downstream.currentContext(); | ||
} | ||
|
||
@Override | ||
protected void hookOnSubscribe(Subscription subscription) { | ||
downstream.onSubscribe(this); | ||
} | ||
|
||
@Override | ||
protected void hookOnNext(T message) { | ||
instrumentation.accept(message, msg -> { | ||
downstream.onNext(msg); | ||
return null; | ||
}); | ||
} | ||
|
||
@Override | ||
protected void hookOnError(Throwable throwable) { | ||
downstream.onError(throwable); | ||
} | ||
|
||
@Override | ||
protected void hookOnComplete() { | ||
downstream.onComplete(); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.