Skip to content

Commit 4636d1d

Browse files
committed
feat(OpenTelemetry): fix generated file for PHP 7.4 compatibility
Signed-off-by: Alexandre Rulleau <[email protected]>
1 parent 0670208 commit 4636d1d

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
lines changed

src/DDTrace/OpenTelemetry/CompositeResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class DatadogResolver implements ResolverInterface
1717
private const DEFAULT_HOST = 'localhost';
1818
private const DEFAULT_SCHEME = 'http';
1919

20-
public function retrieveValue(string $name): mixed
20+
public function retrieveValue(string $name)
2121
{
2222
if (!$this->isMetricsEnabled($name)) {
2323
return null;

src/DDTrace/OpenTelemetry/Configuration.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,21 @@
2222
];
2323

2424
// Helper function to track config access
25-
function track_otel_config_if_whitelisted(string $name, mixed $value): void
25+
function track_otel_config_if_whitelisted(string $name, $value): void
2626
{
2727
if (in_array($name, OTEL_CONFIG_WHITELIST, true)) {
2828
// Convert value to string for telemetry
29-
$value_str = match (true) {
30-
is_bool($value) => $value ? 'true' : 'false',
31-
is_null($value) => '',
32-
is_array($value) => json_encode($value),
33-
is_object($value) => get_class($value),
34-
default => (string)$value,
35-
};
29+
if (is_bool($value)) {
30+
$value_str = $value ? 'true' : 'false';
31+
} elseif (is_null($value)) {
32+
$value_str = '';
33+
} elseif (is_array($value)) {
34+
$value_str = json_encode($value);
35+
} elseif (is_object($value)) {
36+
$value_str = get_class($value);
37+
} else {
38+
$value_str = (string)$value;
39+
}
3640

3741
\dd_trace_internal_fn('track_otel_config', $name, $value_str);
3842
}

src/bridge/_generated_opentelemetry.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,7 @@ class DatadogResolver implements ResolverInterface
11031103
private const HTTP_PORT = '4318';
11041104
private const DEFAULT_HOST = 'localhost';
11051105
private const DEFAULT_SCHEME = 'http';
1106-
public function retrieveValue(string $name): mixed
1106+
public function retrieveValue(string $name)
11071107
{
11081108
if (!$this->isMetricsEnabled($name)) {
11091109
return null;
@@ -1245,17 +1245,21 @@ private function isGrpc(string $protocol): bool
12451245
'OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE',
12461246
];
12471247
// Helper function to track config access
1248-
function track_otel_config_if_whitelisted(string $name, mixed $value): void
1248+
function track_otel_config_if_whitelisted(string $name, $value): void
12491249
{
12501250
if (in_array($name, OTEL_CONFIG_WHITELIST, true)) {
12511251
// Convert value to string for telemetry
1252-
$value_str = match (true) {
1253-
is_bool($value) => $value ? 'true' : 'false',
1254-
is_null($value) => '',
1255-
is_array($value) => json_encode($value),
1256-
is_object($value) => get_class($value),
1257-
default => (string) $value,
1258-
};
1252+
if (is_bool($value)) {
1253+
$value_str = $value ? 'true' : 'false';
1254+
} elseif (is_null($value)) {
1255+
$value_str = '';
1256+
} elseif (is_array($value)) {
1257+
$value_str = json_encode($value);
1258+
} elseif (is_object($value)) {
1259+
$value_str = get_class($value);
1260+
} else {
1261+
$value_str = (string) $value;
1262+
}
12591263
\dd_trace_internal_fn('track_otel_config', $name, $value_str);
12601264
}
12611265
}

0 commit comments

Comments
 (0)