Skip to content

Commit

Permalink
Distributed traces > Pass $headers by reference
Browse files Browse the repository at this point in the history
Because the New Relic extension will fill the values in that
array. If it's not passed by reference, the variable is copied.
  • Loading branch information
adri committed Feb 11, 2022
1 parent 106f948 commit 562d408
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion NewRelic/AdaptiveInteractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public function isSampled(): bool
return $this->interactor->isSampled();
}

public function insertDistributedTracingHeaders(array $headers): void
public function insertDistributedTracingHeaders(array &$headers): void
{
if (!method_exists($this->interactor, 'insertDistributedTracingHeaders')) {
throw new \BadMethodCallException('The decorated interaction does not implement this method');
Expand Down
2 changes: 1 addition & 1 deletion NewRelic/BlackholeInteractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function isSampled(): bool
return true;
}

public function insertDistributedTracingHeaders(array $headers): void
public function insertDistributedTracingHeaders(array &$headers): void
{
}

Expand Down
2 changes: 1 addition & 1 deletion NewRelic/LoggingInteractorDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public function isSampled(): bool
return $isSampled;
}

public function insertDistributedTracingHeaders(array $headers): void
public function insertDistributedTracingHeaders(array &$headers): void
{
$this->logger->debug('Setting New Relic distributed tracing headers', ['headers' => $headers]);

Expand Down
2 changes: 1 addition & 1 deletion NewRelic/NewRelicInteractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public function isSampled(): bool
return newrelic_is_sampled();
}

public function insertDistributedTracingHeaders(array $headers): void
public function insertDistributedTracingHeaders(array &$headers): void
{
if (!function_exists('newrelic_insert_distributed_trace_headers')) {
throw new \BadMethodCallException('You need the "newrelic" extension version 9.8 or higher to use this method');
Expand Down
2 changes: 1 addition & 1 deletion NewRelic/NewRelicInteractorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* @method array getTraceMetadata()
* @method array getLinkingMetadata()
* @method bool isSampled()
* @method void insertDistributedTracingHeaders(array $headers)
* @method void insertDistributedTracingHeaders(array &$headers)
* @method void acceptDistributedTraceHeaders(array $headers, string $transportType = 'HTTP')
*/
interface NewRelicInteractorInterface
Expand Down

0 comments on commit 562d408

Please sign in to comment.