<?php
use OpenTelemetry\Sdk\Trace\PropagationMap;
use OpenTelemetry\Sdk\Trace\TraceContext;
$carrier = getallheaders();
$map = new PropagationMap();
$context = TraceContext::extract($carrier, $map); // <--- this call induces the problem
What is the expected behavior?
No TypeError is raised, and the context is successfully extracted.
What is the actual behavior?
The extract call above induces the following:
Uncaught TypeError: strtolower() expects parameter 1 to be string,
int given in /vendor/open-telemetry/opentelemetry/sdk/Trace/PropagationMap.php:28
Describe your environment
Steps to reproduce
What is the expected behavior?
No TypeError is raised, and the context is successfully extracted.
What is the actual behavior?
The
extract
call above induces the following:Additional context
getallheaders
returns an associative array of request headers (name => value) https://www.php.net/manual/en/function.getallheaders.phpHowever, it appears that
getallheaders
may return integer keys for header names. Consider:This conflicts with the assumption by
PropagationMap
that the$carrier
's keys are all strings, triggering the TypeError fromstrtolower
that we see today. https://github.com/open-telemetry/opentelemetry-php/blob/4c0da3dec054d6fd0d4b570ef1e5f11fe2d7fd88/sdk/Trace/PropagationMap.php#L28