Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit 8746f73

Browse files
committed
Revert propagation header partial changes
1 parent 628c349 commit 8746f73

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

src/Trace/RequestTracer.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,7 @@ public static function start(ReporterInterface $reporter, array $options = [])
128128
? $samplerOptions
129129
: SamplerFactory::build($samplerOptions);
130130

131-
$propagationFormatter = new HttpHeaderFormater();
132-
133-
self::$instance = new RequestHandler($reporter, $sampler, $propagationFormatter, $options);
134-
self::$instance->start($options);
135-
return self::$instance;
131+
return self::$instance = new RequestHandler($reporter, $sampler, $options);
136132
}
137133

138134
/**

src/Trace/TraceContext.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,26 @@ class TraceContext
5252
*/
5353
private $enabled;
5454

55+
/**
56+
* Parses a headers array (normally the $_SERVER variable) and builds a TraceContext objects
57+
*
58+
* @param array $headers The headers array (normally the $_SERVER variable)
59+
* @return TraceContext
60+
*/
61+
public static function fromHeaders($headers)
62+
{
63+
if (array_key_exists(self::HTTP_HEADER, $headers) &&
64+
preg_match(self::CONTEXT_HEADER_FORMAT, $headers[self::HTTP_HEADER], $matches)) {
65+
return new static(
66+
$matches[1],
67+
array_key_exists(2, $matches) ? $matches[2] : null,
68+
array_key_exists(3, $matches) ? $matches[3] == '1' : null,
69+
true
70+
);
71+
}
72+
return new static();
73+
}
74+
5575
/**
5676
* Creates a new TraceContext instance
5777
*

0 commit comments

Comments
 (0)