Skip to content

Comments

Fix queue tracing by injecting trace context into envelope properties instead of body#233

Open
angelvilaplana wants to merge 1 commit intojustbetter:masterfrom
angelvilaplana:fix/unpack-non-array-envelope-body
Open

Fix queue tracing by injecting trace context into envelope properties instead of body#233
angelvilaplana wants to merge 1 commit intojustbetter:masterfrom
angelvilaplana:fix/unpack-non-array-envelope-body

Conversation

@angelvilaplana
Copy link

Summary

This PR fixes an exception thrown when publishing messages to custom topics with non-array payloads.

Previously, the ExchangePlugin attempted to merge Sentry tracing data into the decoded message body using the PHP spread operator. When the payload was not an array (e.g. string or integer), PHP failed to unpack it and threw:

Error: Only arrays and Traversables can be unpacked

This PR changes how Sentry trace data is propagated by injecting it into the envelope properties instead of the message body. This avoids modifying or decoding the payload entirely and works with any payload type.

This PR solves the issue reported in #232

Result

  • Publishing messages with non-array payloads no longer throws exceptions.
  • Messages are enqueued and consumed normally with full tracing enabled (traces_sample_rate = 1.0)
  • Sentry trace context is successfully propagated through envelope properties
  • Message bodies are not decoded, modified, or re-encoded

Checklist

  • I've ran composer run codestyle
  • I've ran composer run analyse

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant