Skip to content

Conversation

hket-tommyluk
Copy link

@hket-tommyluk hket-tommyluk commented Aug 21, 2025

This commit fixes an issue in the Micrometer tracing integration where the parent Observation was not being set on the LettuceObservationContext before the child Observation was created. This could prevent ObservationPredicate implementations from correctly accessing parent context details.

Problem:

When creating a child span from a parent trace context, the parent Observation was being associated with the new Observation object after its creation. This meant that the LettuceObservationContext was not aware of the parent during the creation process, and any ObservationPredicate logic that relied on the parent's presence in the context would fail.

Solution:

To address this, the following changes were made:

  1. MicrometerTracer.nextSpan(…): The logic has been updated to first populate the LettuceObservationContext with the parent Observation. The observation is then created using this fully-populated context.
  2. MicrometerTracer.createObservation(…): The observation factory method has been updated to use a more suitable Micrometer Observation API overload, which accepts both a primary and a default convention for better alignment with Micrometer's practices.
  3. RedisObservation.java: The RedisObservation enum now implements the getDefaultConvention() method, which is necessary to support the updated observation creation logic.

These changes ensure that the observation context is complete before the observation is created, making the tracing integration more robust and aligned with Micrometer's intended usage.

Closes #3406

Make sure that:

  • You have read the contribution guidelines.
  • You have created a feature request first to discuss your contribution intent. Please reference the feature request ticket number in the pull request.
  • You applied code formatting rules using the mvn formatter:format target. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Micrometer Tracing: Context is not ready in ObservationPredicate class
2 participants