rebus-org / Rebus.OpenTelemetry

Other
12 stars 3 forks source link

Handle exception when trying to deserialize data from rbs-ot-correlation-context #8

Open arielmoraes opened 1 year ago

arielmoraes commented 1 year ago

When passing a Baggage the default behavior is to serialize the Dictionary into a JSON, but the size is not validated thus leading to an exception when trying to deserialize the header rbs-ot-correlation-context.

The problem here is when that happens the Exceptions are not being handled, it is not forwarded to the error queue, thus leading to an infinite loop of message processing. Soon I'll try to attach a reproducible sample.

The line that can raise that exception is https://github.com/rebus-org/Rebus.OpenTelemetry/blob/8519b2b532e7694430e9ef320e478e9308f2f321/Rebus.Diagnostics/Diagnostics/Incoming/IncomingDiagnosticsStep.cs#L82

I think we can change the step index to be after the error handling step instead of being the first one or maybe the baggage shouldn't affect the message handling. https://github.com/rebus-org/Rebus.OpenTelemetry/blob/8519b2b532e7694430e9ef320e478e9308f2f321/Rebus.Diagnostics/Config/DiagnosticSourcesConfigurationExtensions.cs#L31