io.opentelemetry.instrumentation.rxjava.v3.common.RxJava3AsyncOperationEndStrategy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of opentelemetry-rxjava-3-common Show documentation
Show all versions of opentelemetry-rxjava-3-common Show documentation
Instrumentation of Java libraries using OpenTelemetry.
The newest version!
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.instrumentation.rxjava.v3.common;
import static io.opentelemetry.instrumentation.api.annotation.support.async.AsyncOperationEndSupport.tryToGetResponse;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.annotation.support.async.AsyncOperationEndStrategy;
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import io.reactivex.rxjava3.core.Completable;
import io.reactivex.rxjava3.core.Flowable;
import io.reactivex.rxjava3.core.Maybe;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.core.Single;
import io.reactivex.rxjava3.functions.Action;
import io.reactivex.rxjava3.functions.BiConsumer;
import io.reactivex.rxjava3.functions.Consumer;
import io.reactivex.rxjava3.parallel.ParallelFlowable;
import java.util.concurrent.atomic.AtomicBoolean;
import org.reactivestreams.Publisher;
public final class RxJava3AsyncOperationEndStrategy implements AsyncOperationEndStrategy {
private static final AttributeKey CANCELED_ATTRIBUTE_KEY =
AttributeKey.booleanKey("rxjava.canceled");
public static RxJava3AsyncOperationEndStrategy create() {
return builder().build();
}
public static RxJava3AsyncOperationEndStrategyBuilder builder() {
return new RxJava3AsyncOperationEndStrategyBuilder();
}
private final boolean captureExperimentalSpanAttributes;
RxJava3AsyncOperationEndStrategy(boolean captureExperimentalSpanAttributes) {
this.captureExperimentalSpanAttributes = captureExperimentalSpanAttributes;
}
@Override
public boolean supports(Class> returnType) {
return returnType == Publisher.class
|| returnType == Completable.class
|| returnType == Maybe.class
|| returnType == Single.class
|| returnType == Observable.class
|| returnType == Flowable.class
|| returnType == ParallelFlowable.class;
}
@Override
public Object end(
Instrumenter instrumenter,
Context context,
REQUEST request,
Object asyncValue,
Class responseType) {
EndOnFirstNotificationConsumer