sdk-java icon indicating copy to clipboard operation
sdk-java copied to clipboard

MDC Context not propogating

Open karunagoyal opened this issue 2 years ago • 4 comments

Expected Behavior

MDC context should propogate to Temporal Threads with spring boot sdk

Actual Behavior

MDC Context not getting propogated

Steps to Reproduce the Problem

1.Set up MDC Context Propogator in code

  1. Check logs from Temporal and no MDC context present

Specifications

  • Version: temporal-spring-boot-starter-alpha, 1.20.1
  • Platform:

karunagoyal avatar Jan 26 '24 18:01 karunagoyal

Modifying the SpringBoot sample to have a MDC context propagator I had no issue propagating a value from the client or workflow to an Activity.

https://github.com/Quinn-With-Two-Ns/samples-java/commit/c99e24af5f20d1965827c5e178f6541a9b5ddf12

Quinn-With-Two-Ns avatar Jan 26 '24 21:01 Quinn-With-Two-Ns

If you can share more details about your setup, ideally in a self contained example, I can try to help narrow down where the error is.

Quinn-With-Two-Ns avatar Jan 26 '24 21:01 Quinn-With-Two-Ns

Thanks @Quinn-With-Two-Ns . I do have workflow client bean create like this @Bean public WorkflowClient workflowClient(DataConverter dataConverter, MdcContextPropagator mdcContextPropagator) { WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs(); WorkflowClientOptions workflowClientOptions = WorkflowClientOptions.newBuilder().setDataConverter(dataConverter).setContextPropagators(Collections.singletonList(mdcContextPropagator)).build(); return WorkflowClient.newInstance(service, workflowClientOptions); } still I donot see MDC context getting propogated

karunagoyal avatar Jan 29 '24 21:01 karunagoyal

@karunagoyal You need to also be setting the the context propagator on the client the worker uses. You can see how in TemporalOptionsConfig.java in the code I posted.

Quinn-With-Two-Ns avatar Jan 30 '24 01:01 Quinn-With-Two-Ns