-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add B3 multi header propagation support (#495)
* Add support for B3Multi headers propagation Some services expect [B3 Multi][1] headers as input information. To support that we need to be able to Inject them into upstream requests. Lowercase headers used to be [compatible][2] with Istio Envoy. Tests will be added as a separate commit later on. Solving #36 [1]: https://github.com/openzipkin/b3-propagation#multiple-headers [2]: open-telemetry/opentelemetry-go#765 * add tests for b3 multi propagation --------- Co-authored-by: Vladimir Kuznichenkov <kuzaxak.tech@gmail.com> Co-authored-by: Vladimir Kuznichenkov <5330267+kuzaxak@users.noreply.github.com>
- Loading branch information
1 parent
e1ef658
commit c80826c
Showing
8 changed files
with
234 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
$b3_trace_id = $_SERVER["HTTP_B3_TRACEID"]; | ||
$b3_span_id = $_SERVER["HTTP_B3_SPANID"]; | ||
$b3_sampled = $_SERVER["HTTP_B3_SAMPLED"]; | ||
|
||
if (!preg_match("/^([0-9a-f]{32}|[0-9a-f]{16})$/", $b3_trace_id)) { | ||
throw new Exception("invalid or missing x-b3-traceid header"); | ||
} | ||
|
||
if (!preg_match("/^[0-9a-f]{16}$/", $b3_span_id)) { | ||
throw new Exception("invalid or missing x-b3-spanid header"); | ||
} | ||
|
||
if (!preg_match("/^[0-1]$/", $b3_sampled)) { | ||
throw new Exception("invalid or missing x-b3-sampled header"); | ||
} | ||
|
||
header("Content-Type: application/json"); | ||
echo(json_encode(array( | ||
"x-b3-traceid" => $b3_trace_id, | ||
"x-b3-spanid" => $b3_span_id, | ||
"x-b3-sampled" => $b3_sampled | ||
))); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.