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

Add support for W3C traceparent header #1680

Merged
merged 4 commits into from
Jan 18, 2024
Merged

Add support for W3C traceparent header #1680

merged 4 commits into from
Jan 18, 2024

Conversation

cleptric
Copy link
Member

}

if (isset($matches['sampled'])) {
$context->parentSampled = $matches['sampled'] === '01';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://www.w3.org/TR/trace-context/#trace-flags

While this is a hex-encoded bit field, I think we can get away with just checking for 01, as the other values are either 00 or omitting it altogether.

$sampled = $this->sampled ? '-01' : '-00';
}

return sprintf('00-%s-%s%s', (string) $this->traceId, (string) $this->spanId, $sampled);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://www.w3.org/TR/trace-context/#version-format

Hardcoding the version to 00 seems to be okay.

@cleptric cleptric marked this pull request as ready for review January 18, 2024 09:48
@cleptric cleptric enabled auto-merge (squash) January 18, 2024 14:28
@cleptric cleptric merged commit a31d418 into master Jan 18, 2024
31 checks passed
@cleptric cleptric deleted the traceparent branch January 18, 2024 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants