Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TRACE_CONTEXT_PATTERN expects the options part to always be present, but it can be missing #655

Open
andreibarabas opened this issue Nov 20, 2024 · 0 comments
Assignees

Comments

@andreibarabas
Copy link

The regex here

const TRACE_CONTEXT_PATTERN = /^(?<traceId>\w+)\/(?<spanId>\d+);o=(?<options>.+)$/;

expects the options part to always be present, but most of the time it's actually not
Screenshot 2024-11-20 at 12 23 42

If you look at firebase-functions they also have the options part as optional.

Here is the solution

-const TRACE_CONTEXT_PATTERN = /^(?<traceId>\w+)\/(?<spanId>\d+);o=(?<options>.+)$/;
+const TRACE_CONTEXT_PATTERN = /^(?<traceId>\w+)\/(?<spanId>\d+)(?:;o=(?<options>.+))?$/;
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

No branches or pull requests

2 participants