Skip to content

Commit

Permalink
Use Gradle 7.4 (#28)
Browse files Browse the repository at this point in the history
use Gradle 7.4
  • Loading branch information
burtbeckwith authored Feb 8, 2022
1 parent 6d4635f commit 3aa9e8a
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 55 deletions.
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
1 change: 0 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ include 'tracing-zipkin'
include 'tests:kotlin-tests'

enableFeaturePreview 'TYPESAFE_PROJECT_ACCESSORS'
enableFeaturePreview 'VERSION_CATALOGS'

dependencyResolutionManagement {
repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import io.micronaut.context.annotation.Requires
import io.micronaut.core.annotation.Introspected
import io.micronaut.http.HttpRequest
import io.micronaut.http.MutableHttpResponse
import io.micronaut.http.annotation.*
import io.micronaut.http.annotation.Body
import io.micronaut.http.annotation.Controller
import io.micronaut.http.annotation.Filter
import io.micronaut.http.annotation.Filter.MATCH_ALL_PATTERN
import io.micronaut.http.annotation.Get
import io.micronaut.http.annotation.Post
import io.micronaut.http.client.HttpClient
import io.micronaut.http.filter.HttpServerFilter
import io.micronaut.http.filter.ServerFilterChain
Expand All @@ -27,12 +32,13 @@ import reactor.core.publisher.Mono
import reactor.util.context.Context
import reactor.util.function.Tuple2
import reactor.util.function.Tuples
import java.util.*
import java.util.UUID

class ReactorContextPropagationSpec {

@Test
fun testKotlinPropagation() {

val embeddedServer = ApplicationContext.run(EmbeddedServer::class.java,
mapOf("reactortestpropagation.enabled" to "true", "micronaut.http.client.read-timeout" to "30s")
)
Expand All @@ -41,7 +47,8 @@ class ReactorContextPropagationSpec {
val result: MutableList<Tuple2<String, String>> = Flux.range(1, 100)
.flatMap {
val tracingId = UUID.randomUUID().toString()
val get = HttpRequest.POST<Any>("http://localhost:${embeddedServer.port}/trigger", NameRequestBody("sss-" + tracingId)).header("X-TrackingId", tracingId)
val get = HttpRequest.POST<Any>("http://localhost:${embeddedServer.port}/trigger", NameRequestBody("sss-" + tracingId))
.header("X-TrackingId", tracingId)
Mono.from(client.retrieve(get, String::class.java))
.map { Tuples.of(it as String, tracingId) }
}
Expand All @@ -54,8 +61,6 @@ class ReactorContextPropagationSpec {

embeddedServer.stop()
}


}

@Requires(property = "reactortestpropagation.enabled")
Expand All @@ -74,7 +79,6 @@ class TestController(private val someService: SomeService) {
val reactorContextView = currentCoroutineContext()[ReactorContext.Key]!!.context
return reactorContextView.get("reactorTrackingId") as String
}

}

@Introspected
Expand All @@ -97,11 +101,10 @@ class SomeService {
suspendTrackingId
}
}

}

@Requires(property = "reactortestpropagation.enabled")
@Filter(Filter.MATCH_ALL_PATTERN)
@Filter(MATCH_ALL_PATTERN)
class ReactorHttpServerFilter : HttpServerFilter {

override fun doFilter(request: HttpRequest<*>, chain: ServerFilterChain): Publisher<MutableHttpResponse<*>> {
Expand All @@ -115,7 +118,7 @@ class ReactorHttpServerFilter : HttpServerFilter {
}

@Requires(property = "reactortestpropagation.enabled")
@Filter(Filter.MATCH_ALL_PATTERN)
@Filter(MATCH_ALL_PATTERN)
class SuspendHttpServerFilter : CoroutineHttpServerFilter {

override suspend fun filter(request: HttpRequest<*>, chain: ServerFilterChain): MutableHttpResponse<*> {
Expand All @@ -138,11 +141,10 @@ interface CoroutineHttpServerFilter : HttpServerFilter {
filter(request, chain)
}
}

}

suspend fun ServerFilterChain.next(request: HttpRequest<*>): MutableHttpResponse<*> {
return this.proceed(request).asFlow().single()
return proceed(request).asFlow().single()
}

@Introspected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ public void doOnError(@NonNull Throwable error, @NonNull Span span) {
}
setErrorTags(span, error);
}

});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ public boolean isContinued() {
public boolean isFinishOnError() {
return false;
}

});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* @author Denis Stepanov
*/
@SuppressWarnings("PublisherImplementation")
public class TracingCorePublisher<T> extends TracingPublisher<T> implements CorePublisher<T> {
public class TracingCorePublisher<T> extends TracingPublisher<T> implements CorePublisher<T> {

/**
* Creates a new tracing publisher for the given arguments.
Expand All @@ -40,7 +40,9 @@ public class TracingCorePublisher<T> extends TracingPublisher<T> implements Cor
* @param tracer the tracer
* @param operationName the operation name that should be started
*/
public TracingCorePublisher(CorePublisher<T> publisher, Tracer tracer, String operationName) {
public TracingCorePublisher(CorePublisher<T> publisher,
Tracer tracer,
String operationName) {
super(publisher, tracer, operationName);
}

Expand All @@ -52,7 +54,10 @@ public TracingCorePublisher(CorePublisher<T> publisher, Tracer tracer, String op
* @param operationName the operation name that should be started
* @param tracingObserver the tracing observer
*/
public TracingCorePublisher(CorePublisher<T> publisher, Tracer tracer, String operationName, TracingObserver tracingObserver) {
public TracingCorePublisher(CorePublisher<T> publisher,
Tracer tracer,
String operationName,
TracingObserver tracingObserver) {
super(publisher, tracer, operationName, tracingObserver);
}

Expand All @@ -63,7 +68,8 @@ public TracingCorePublisher(CorePublisher<T> publisher, Tracer tracer, String op
* @param publisher the target publisher
* @param tracer the tracer
*/
public TracingCorePublisher(CorePublisher<T> publisher, Tracer tracer) {
public TracingCorePublisher(CorePublisher<T> publisher,
Tracer tracer) {
super(publisher, tracer);
}

Expand All @@ -75,7 +81,9 @@ public TracingCorePublisher(CorePublisher<T> publisher, Tracer tracer) {
* @param tracer the tracer
* @param tracingObserver the tracing observer
*/
public TracingCorePublisher(CorePublisher<T> publisher, Tracer tracer, TracingObserver tracingObserver) {
public TracingCorePublisher(CorePublisher<T> publisher,
Tracer tracer,
TracingObserver tracingObserver) {
super(publisher, tracer, tracingObserver);
}

Expand All @@ -86,7 +94,9 @@ public TracingCorePublisher(CorePublisher<T> publisher, Tracer tracer, TracingOb
* @param tracer the tracer
* @param spanBuilder the span builder that represents the span that will be
*/
public TracingCorePublisher(CorePublisher<T> publisher, Tracer tracer, SpanBuilder spanBuilder) {
public TracingCorePublisher(CorePublisher<T> publisher,
Tracer tracer,
SpanBuilder spanBuilder) {
super(publisher, tracer, spanBuilder);
}

Expand All @@ -98,7 +108,10 @@ public TracingCorePublisher(CorePublisher<T> publisher, Tracer tracer, SpanBuild
* @param spanBuilder the span builder that represents the span that will be
* @param tracingObserver the tracing observer
*/
public TracingCorePublisher(CorePublisher<T> publisher, Tracer tracer, SpanBuilder spanBuilder, TracingObserver tracingObserver) {
public TracingCorePublisher(CorePublisher<T> publisher,
Tracer tracer,
SpanBuilder spanBuilder,
TracingObserver tracingObserver) {
super(publisher, tracer, spanBuilder, tracingObserver);
}

Expand All @@ -111,7 +124,10 @@ public TracingCorePublisher(CorePublisher<T> publisher, Tracer tracer, SpanBuild
* be created when the publisher is subscribed to
* @param isSingle true if the publisher emits a single item
*/
public TracingCorePublisher(CorePublisher<T> publisher, Tracer tracer, SpanBuilder spanBuilder, boolean isSingle) {
public TracingCorePublisher(CorePublisher<T> publisher,
Tracer tracer,
SpanBuilder spanBuilder,
boolean isSingle) {
super(publisher, tracer, spanBuilder, isSingle);
}

Expand All @@ -125,7 +141,11 @@ public TracingCorePublisher(CorePublisher<T> publisher, Tracer tracer, SpanBuild
* @param isSingle true if the publisher emits a single item
* @param tracingObserver the tracing observer
*/
public TracingCorePublisher(CorePublisher<T> publisher, Tracer tracer, SpanBuilder spanBuilder, boolean isSingle, TracingObserver tracingObserver) {
public TracingCorePublisher(CorePublisher<T> publisher,
Tracer tracer,
SpanBuilder spanBuilder,
boolean isSingle,
TracingObserver tracingObserver) {
super(publisher, tracer, spanBuilder, isSingle, tracingObserver);
}

Expand All @@ -135,7 +155,10 @@ public void subscribe(CoreSubscriber<? super T> subscriber) {
}

@Override
protected void doSubscribe(Subscriber<? super T> actual, ScopeManager scopeManager, Span span, boolean finishOnClose) {
protected void doSubscribe(Subscriber<? super T> actual,
ScopeManager scopeManager,
Span span,
boolean finishOnClose) {
CoreSubscriber<? extends T> coreActual = (CoreSubscriber<? extends T>) actual;
publisher.subscribe(new TracingCoreSubscriber(scopeManager, span, actual, finishOnClose, coreActual.currentContext()));
}
Expand All @@ -144,7 +167,11 @@ private final class TracingCoreSubscriber extends TracingSubscriber implements C

private final Context context;

public TracingCoreSubscriber(ScopeManager scopeManager, Span span, Subscriber<? super T> actual, boolean finishOnClose, Context context) {
public TracingCoreSubscriber(ScopeManager scopeManager,
Span span,
Subscriber<? super T> actual,
boolean finishOnClose,
Context context) {
super(scopeManager, span, actual, finishOnClose);
this.context = context;
}
Expand All @@ -154,5 +181,4 @@ public Context currentContext() {
return context;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,31 @@ public interface TracingObserver<T> {
TracingObserver<?> NO_OP = new TracingObserver<Object>() { };

/**
* Designed for subclasses to override if the current active span is to be continued by this publisher. False by default.
* This only has effects if no spanBuilder was defined.
* Designed for subclasses to override if the current active span is to be
* continued by this publisher. False by default. This only has effects if
* no spanBuilder was defined.
*
* @return true, if the current span should be continued by this publisher
* @since 2.0.3
* @since 4.0.2
*/
default boolean isContinued() {
return false;
}

/**
* Designed for subclasses to override if the span needs to be finished upon error. True by default.
* Designed for subclasses to override if the span needs to be finished
* upon error. True by default.
*
* @return true, if the active span needs to be finished on error
* @since 2.0.3
* @since 4.0.2
*/
default boolean isFinishOnError() {
return true;
}

/**
* Designed for subclasses to override and implement custom behaviour when an item is emitted.
* Designed for subclasses to override and implement custom behaviour when
* an item is emitted.
*
* @param object The object
* @param span The span
Expand All @@ -72,8 +75,8 @@ default void doOnSubscribe(@NonNull Span span) {
}

/**
* Designed for subclasses to override and implement custom on finish behaviour. Fired
* prior to calling {@link Span#finish()}.
* Designed for subclasses to override and implement custom on finish
* behaviour. Fired prior to calling {@link Span#finish()}.
*
* @param span The span
*/
Expand All @@ -91,5 +94,4 @@ default void doOnFinish(@NonNull Span span) {
default void doOnError(@NonNull Throwable throwable, @NonNull Span span) {
// no-op
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public class TracingPublisher<T> implements Publishers.MicronautPublisher<T> {
/**
* Creates a new tracing publisher for the given arguments.
*
* @param publisher the target publisher
* @param tracer the tracer
* @param operationName the operation name that should be started
* @param publisher the target publisher
* @param tracer the tracer
* @param operationName the operation name that should be started
*/
public TracingPublisher(Publisher<T> publisher,
Tracer tracer,
Expand All @@ -81,8 +81,8 @@ public TracingPublisher(Publisher<T> publisher,
* Creates a new tracing publisher for the given arguments. This constructor
* will just add tracing of the existing span if it is present.
*
* @param publisher the target publisher
* @param tracer the tracer
* @param publisher the target publisher
* @param tracer the tracer
*/
public TracingPublisher(Publisher<T> publisher, Tracer tracer) {
this(publisher, tracer, (SpanBuilder) null, TracingObserver.NO_OP);
Expand All @@ -105,9 +105,9 @@ public TracingPublisher(Publisher<T> publisher,
/**
* Creates a new tracing publisher for the given arguments.
*
* @param publisher the target publisher
* @param tracer the tracer
* @param spanBuilder the span builder that represents the span that will be
* @param publisher the target publisher
* @param tracer the tracer
* @param spanBuilder the span builder that represents the span that will be
*/
public TracingPublisher(Publisher<T> publisher,
Tracer tracer,
Expand All @@ -133,11 +133,11 @@ public TracingPublisher(Publisher<T> publisher,
/**
* Creates a new tracing publisher for the given arguments.
*
* @param publisher the target publisher
* @param tracer the tracer
* @param spanBuilder the span builder that represents the span that will
* be created when the publisher is subscribed to
* @param isSingle true if the publisher emits a single item
* @param publisher the target publisher
* @param tracer the tracer
* @param spanBuilder the span builder that represents the span that will
* be created when the publisher is subscribed to
* @param isSingle true if the publisher emits a single item
*/
public TracingPublisher(Publisher<T> publisher,
Tracer tracer,
Expand Down
Loading

0 comments on commit 3aa9e8a

Please sign in to comment.