Skip to content

Micrometer Tracing: Context is not ready in ObservationPredicate class #3406

@hket-tommyluk

Description

@hket-tommyluk

Bug Report

Current Behavior

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 ObservationConvention logic that relied on the parent's presence in the context would fail.

Input Code

Input Code
	@Bean
	protected ObservationPredicate observationPredicate() {
		return (name, context) -> {
			if (context instanceof LettuceObservationContext) {
				// currently context.getParentObservation() is always null.
				return context.getParentObservation() != null;
			}
		};
	}

Expected behavior/code

context.getParentObservation() returns the parent observation.

Environment

  • Lettuce version(s): 6.5.5.RELEASE
  • Redis version: 7.2.5

Possible Solution

Preparing context before creating observation.

Additional context

https://github.com/redis/lettuce/blob/main/src/main/java/io/lettuce/core/tracing/MicrometerTracing.java#L143

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions