Skip to content

Rework lettuce reactive client instrumentation - #3049

Merged
jbachorik merged 18 commits into
masterfrom
jb/lettuce_checkpoints
Sep 23, 2021
Merged

jbachorik merged 18 commits into
masterfrom
jb/lettuce_checkpoints

Conversation

@jbachorik

@jbachorik jbachorik commented Aug 31, 2021 •

Copy link
Copy Markdown
Contributor

The Lettuce reactive client is based on Reactive Streams

The whole command execution process is driven by an associated io.lettuce.core.RedisPublisher#RedisSubscription instance which creates a reactor.core.publisher.Mono (for a singleton command) or reactor.core.publisher.Flux (for a command set) instance.

Once the subscription is created the client will subscribe to it and by doing this will trigger the reactive command processing.
As a part of the subscription process a special io.lettuce.core.RedisPublisher.SubscriptionCommand wrapper command instance is created which will be handed over for transmission to Redis in io.lettuce.core.RedisPublisher.RedisSubscription#dispatchCommand() method. At exactly this point the associated span can be marked for migration as the Redis response (if any) may be processed by a different thread.

When the response is received back from Redis server the subscription command is connected with the incoming data and io.lettuce.core.RedisPublisher.SubscriptionCommand#complete() method is invoked to start processing the response. At this point the command span migration can be finalized as the span processing resumes on this particular thread.

When it is a set of commands that is being executed we want to have the information about the number of processed commands - this can be achieved by hooking into io.lettuce.core.RedisPublisher.RedisSubscription#onNext(Object) method, incrementing the tracked count until the associated subscription command has been cancelled. In order to propagate the parent span active at the time of issuing the Redis command it is necessary to instrument
io.lettuce.core.AbstractRedisReactiveCommands, intercepting all createMono and create*Flux methods - capturing the parent span when reactor.core.publisher.Mono or reactor.core.publisher.Flux instance is created and reactivating each time they are subscribed.

@jbachorik
jbachorik force-pushed the jb/lettuce_checkpoints branch from 910c136 to 992816a Compare September 13, 2021 10:38
@jbachorik jbachorik changed the title Emit suspend/resume checkpoints for lettuce reactive client Do not emit checkpoints for reactive lettuce client subscription Sep 13, 2021
@jbachorik
jbachorik force-pushed the jb/lettuce_checkpoints branch from 992816a to 1dc4b5f Compare September 15, 2021 16:14
@jbachorik jbachorik changed the title Do not emit checkpoints for reactive lettuce client subscription Rework lettuce reactive client instrumentation Sep 15, 2021
@jbachorik
jbachorik force-pushed the jb/lettuce_checkpoints branch from d6e5a32 to c46aea3 Compare September 20, 2021 10:25
@devinsba

Copy link
Copy Markdown
Contributor

This looks good to me. I think we might want to generalize some of this into the reactor instrumentation at some point but I like starting with the more specific instrumentation here

bantonsson and others added 2 commits September 20, 2021 16:33
…oke-test

Add resource to RabbitMQ smoke test
…trace/instrumentation/lettuce5/LettuceReactiveClientInstrumentation.java

Co-authored-by: Brian Devins-Suresh <brian.devinssuresh@datadoghq.com>
@jbachorik
jbachorik marked this pull request as ready for review September 21, 2021 09:27
@jbachorik
jbachorik requested a review from a team as a code owner September 21, 2021 09:27
mcculls and others added 2 commits September 21, 2021 10:49
* Add dd.jms.legacy.tracing.enabled system property (default to true)
* Add structures to track batch JMS messages
* Track time-in-queue spans per-session-thread
* Cleanup active scopes and time-in-queue spans on every session commit/rollback/ack/close
* Finish time-in-queue spans on each receive/onMessage (for auto-ack) or when closing consumer
* Support inject/extract of batch id and produced time
* Assign ids to message batches
* Inject produce time and extract it into a time-in-queue span when consuming
* Use configured serviceName
* Only expose batch-state to producers
* Test time-in-queue generation
* Test batch time-in-queue generation
* Handle WebLogic JMS destinations which mix all APIs (Queue/Topic/Temporary...) in the same type
* Use current context's service name on producer side, while using configured service name on consumer side
* Widen JMS WebLogic check to cover both DestinationImpl and DistributedDestinationImpl
* Expand explanation of WebLogic handling
* Evict entries by age if can't evict by liveliness
* Order correctly the expected and actual for assertEquals

* Enable OldObjectSample by default in dd.jfp

That is to bring the the Heap Profiler to GA for Java.

@devinsba devinsba left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good once you delete the advice that isn't used

mcculls and others added 6 commits September 23, 2021 09:54
…at are only ever used synchronously and could be re-used. (#3087)

Turning off async propagation for `TransactionBroker.beginTransaction` stops those `FutureTask` instances from being captured when the transaction is constructed and results in better checkpoints for ActiveMQ (we can't exclude these instances by type because their type is `FutureTask`, ie. they don't extend it.)
@jbachorik
jbachorik requested a review from a team as a code owner September 23, 2021 10:31
@jbachorik
jbachorik merged commit a73922c into master Sep 23, 2021
@jbachorik
jbachorik deleted the jb/lettuce_checkpoints branch September 23, 2021 12:27
@github-actions github-actions Bot added this to the 0.88.0 milestone Sep 23, 2021
@bantonsson bantonsson added the tag: no release notes Changes to exclude from release notes label Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tag: no release notes Changes to exclude from release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants