eclipse / microprofile-reactive-messaging

Apache License 2.0
60 stars 36 forks source link

Context propagation #72

Open pavolloffay opened 4 years ago

pavolloffay commented 4 years ago

I am creating this based on https://github.com/smallrye/smallrye-reactive-messaging/issues/214

Allow in-process context propagation between handlers. The API can be used by users to propagate any objects between handlers, but It is also necessary for tracing to propagate span context object to be able to link spans in handlers:

@Incoming("data-processor-in")
@Outgoing("data-processor-out")
public CompletionStage<KafkaMessage<String, String>> send(KafkaMessage<String, String> message) {
  CompletableFuture<KafkaMessage<String, String>> future = new CompletableFuture<>();
  future.complete(KafkaMessage.ofAndTraced(message.getKey(), message.getPayload().toUpperCase(), message.getSpan()));
  return future;
}

links span from data-processor-in to data-processor-out topics.

Two solutions have been already discussed:

Once the context propagation is in place we could provide tracing for underlying messaging platforms but in addition to also model invocations of the handlers themselves.

Other

Related to #2?

Emily-Jiang commented 4 years ago

I think it is much better to integrate with context propagation as it was created to server the purpose of this spec and Fault Tolerance.

pilhuhn commented 4 years ago

Where do we stand here? I think it is important to solve that rather sooner than later as any (reactive) messaging things are becoming more popular these days.

cescoffier commented 4 years ago

SmallRye includes in its last version metadata propagation (metadata associated with messages) and supports context propagation (capture of the context and propagation to the subscriber).

Emily-Jiang commented 4 years ago

See See https://smallrye.io/smallrye-reactive-messaging/smallrye-reactive-messaging/2/concepts.html#messages