Skip to content

Commit

Permalink
format code style
Browse files Browse the repository at this point in the history
  • Loading branch information
kaibocai7 committed Mar 5, 2023
1 parent 5fec045 commit c8edf4d
Show file tree
Hide file tree
Showing 16 changed files with 124 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.instrumentation.rxjava.v3.common;

import io.opentelemetry.api.GlobalOpenTelemetry;
Expand All @@ -6,9 +11,9 @@
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import io.reactivex.rxjava3.core.Single;
import io.reactivex.rxjava3.disposables.Disposable;
import org.junit.jupiter.api.Test;
import java.util.Random;
import java.util.concurrent.CountDownLatch;
import org.junit.jupiter.api.Test;

public abstract class AbstractRxJava3SubscriptionTest {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.instrumentation.rxjava.v3.common;

import static io.opentelemetry.sdk.testing.assertj.LogAssertions.assertThat;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.attributeEntry;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import com.google.common.primitives.Ints;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.instrumentation.testing.InstrumentationTestRunner;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;

import static io.opentelemetry.sdk.testing.assertj.LogAssertions.assertThat;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.attributeEntry;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import io.opentelemetry.instrumentation.testing.util.ThrowingRunnable;
import io.opentelemetry.instrumentation.testing.util.ThrowingSupplier;
import io.opentelemetry.sdk.testing.assertj.TraceAssert;
Expand All @@ -21,19 +25,20 @@
import io.reactivex.rxjava3.core.Scheduler;
import io.reactivex.rxjava3.core.Single;
import io.reactivex.rxjava3.internal.operators.flowable.FlowablePublish;
import io.reactivex.rxjava3.internal.operators.observable.ObservablePublish;
import io.reactivex.rxjava3.schedulers.Schedulers;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.stream.Stream;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.stream.Stream;

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public abstract class AbstractRxJava3Test {
Expand Down Expand Up @@ -191,7 +196,7 @@ public void basicFlowable() {
}

@Test
public void towOperationsFlowable() {
public void twoOperationsFlowable() {
List<Integer> result =
createParentSpan(
() ->
Expand Down Expand Up @@ -287,7 +292,7 @@ public void delayedTwiceFlowable() {
}

@Test
public void MaybeFromCallable() {
public void maybeFromCallable() {
Integer result =
createParentSpan(
() -> Maybe.fromCallable(() -> addOne(10)).map(this::addOne).blockingGet());
Expand Down Expand Up @@ -360,6 +365,28 @@ public void connectableFlowable() {
.hasParent(trace.getSpan(0))));
}

@Test
public void connectableObservable() {
List<Integer> result =
createParentSpan(
() ->
ObservablePublish.just(0)
.delay(100, TimeUnit.MILLISECONDS)
.map(this::addOne)
.toList()
.blockingGet());
assertThat(result).contains(1);
testing()
.waitAndAssertTraces(
trace ->
trace.hasSpansSatisfyingExactly(
span -> span.hasName(PARENT).hasKind(SpanKind.INTERNAL).hasNoParent(),
span ->
span.hasName(ADD_ONE)
.hasKind(SpanKind.INTERNAL)
.hasParent(trace.getSpan(0))));
}

@Test
public void maybeError() {
IllegalStateException error = new IllegalStateException(EXCEPTION_MESSAGE);
Expand Down Expand Up @@ -397,7 +424,7 @@ public void singleError() {
}

@Test
public void ObservableError() {
public void observableError() {
IllegalStateException error = new IllegalStateException(EXCEPTION_MESSAGE);
assertThatThrownBy(() -> createParentSpan(() -> Observable.error(error).toList().blockingGet()))
.isEqualTo(error);
Expand Down Expand Up @@ -509,7 +536,7 @@ public void basicSingleCancel() {
}

@Test
public void basicCompletable() {
public void basicCompletableCancel() {
createParentSpan(
() ->
Completable.fromCallable(() -> 1)
Expand All @@ -523,7 +550,7 @@ public void basicCompletable() {
}

@Test
public void observableCancel() {
public void basicObservableCancel() {
createParentSpan(
() ->
Observable.just(1)
Expand Down Expand Up @@ -566,7 +593,7 @@ public void basicMaybeChain() {
}

@Test
public void basicFLowableChain() {
public void basicFlowableChain() {
createParentSpan(
() ->
Flowable.fromIterable(Ints.asList(5, 6))
Expand Down Expand Up @@ -604,7 +631,7 @@ public void basicFLowableChain() {

// Publisher chain spans have the correct parents from subscription time
@Test
public void maybeParentSpan() {
public void maybeChainParentSpan() {
testing()
.runWithSpan(
"trace-parent", () -> Maybe.just(42).map(this::addOne).map(this::addTwo).blockingGet());
Expand Down Expand Up @@ -724,7 +751,7 @@ public void singleChainHasAssemblyContext() {
}

@Test
public void observalbeChainHasAssemblyContext() {
public void observableChainHasAssemblyContext() {
List<Integer> result =
createParentSpan(
() -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.instrumentation.rxjava.v3.common;

import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.satisfies;
import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.CODE_FUNCTION;
import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.CODE_NAMESPACE;
import static org.assertj.core.api.Assertions.assertThat;

import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.instrumentation.testing.InstrumentationTestRunner;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;

import io.opentelemetry.sdk.trace.data.SpanData;
import io.opentelemetry.sdk.trace.data.StatusData;
import io.reactivex.rxjava3.core.Completable;
Expand All @@ -19,19 +29,12 @@
import io.reactivex.rxjava3.subjects.SingleSubject;
import io.reactivex.rxjava3.subjects.UnicastSubject;
import io.reactivex.rxjava3.subscribers.TestSubscriber;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.reactivestreams.Publisher;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;

import java.util.List;

import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.satisfies;
import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.CODE_FUNCTION;
import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.CODE_NAMESPACE;
import static org.assertj.core.api.Assertions.assertThat;

public abstract class AbstractRxJava3WithSpanTest {
private static final AttributeKey<Boolean> RXJAVA_CANCELED =
AttributeKey.booleanKey("rxjava.canceled");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
* from different traces.
*/
public class RxJava3ConcurrencyTestHelper {
private RxJava3ConcurrencyTestHelper() {
}
private RxJava3ConcurrencyTestHelper() {}

public static void launchAndWait(
Scheduler scheduler, int iterations, long timeoutMillis, InstrumentationTestRunner runner) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

import io.opentelemetry.instrumentation.rxjava.v3.common.AbstractRxJava3SubscriptionTest;
import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

import io.opentelemetry.instrumentation.rxjava.v3.common.AbstractRxJava3WithSpanTest;
import io.opentelemetry.instrumentation.rxjava.v3.common.AbstractTracedWithSpan;
import io.opentelemetry.instrumentation.rxjava.v3.common.extensionannotation.TracedWithSpan;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

import io.opentelemetry.instrumentation.rxjava.v3.common.AbstractRxJava3WithSpanTest;
import io.opentelemetry.instrumentation.rxjava.v3.common.AbstractTracedWithSpan;
import io.opentelemetry.instrumentation.rxjava.v3.common.extensionannotation.TracedWithSpan;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

import io.opentelemetry.instrumentation.rxjava.v3.common.AbstractRxJava3Test;
import io.opentelemetry.instrumentation.testing.AgentTestRunner;
import io.opentelemetry.instrumentation.testing.InstrumentationTestRunner;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

import io.opentelemetry.instrumentation.rxjava.v3.common.AbstractRxJava3SubscriptionTest;
import io.opentelemetry.instrumentation.rxjava.v3_0.TracingAssembly;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

import io.opentelemetry.instrumentation.rxjava.v3.common.AbstractRxJava3Test;
import io.opentelemetry.instrumentation.rxjava.v3_0.TracingAssembly;
import io.opentelemetry.instrumentation.testing.InstrumentationTestRunner;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

import io.opentelemetry.instrumentation.rxjava.v3.common.AbstractRxJava3SubscriptionTest;
import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

import io.opentelemetry.instrumentation.rxjava.v3.common.AbstractRxJava3WithSpanTest;
import io.opentelemetry.instrumentation.rxjava.v3.common.AbstractTracedWithSpan;
import io.opentelemetry.instrumentation.rxjava.v3.common.extensionannotation.TracedWithSpan;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

import io.opentelemetry.instrumentation.rxjava.v3.common.AbstractRxJava3WithSpanTest;
import io.opentelemetry.instrumentation.rxjava.v3.common.AbstractTracedWithSpan;
import io.opentelemetry.instrumentation.rxjava.v3.common.extensionannotation.TracedWithSpan;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

import io.opentelemetry.instrumentation.rxjava.v3.common.AbstractRxJava3Test;
import io.opentelemetry.instrumentation.testing.AgentTestRunner;
import io.opentelemetry.instrumentation.testing.InstrumentationTestRunner;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

import io.opentelemetry.instrumentation.rxjava.v3.common.AbstractRxJava3SubscriptionTest;
import io.opentelemetry.instrumentation.rxjava.v3_1_1.TracingAssembly;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

import io.opentelemetry.instrumentation.rxjava.v3.common.AbstractRxJava3Test;
import io.opentelemetry.instrumentation.rxjava.v3_1_1.TracingAssembly;
import io.opentelemetry.instrumentation.testing.InstrumentationTestRunner;
Expand Down

0 comments on commit c8edf4d

Please sign in to comment.