Skip to content

Commit 1a21be8

Browse files
authored
fix(DependencyInjection/Configuration): normalize headers format according to PSR HTTP transport (#167)
1 parent e334eed commit 1a21be8

5 files changed

Lines changed: 12 additions & 25 deletions

File tree

src/DependencyInjection/Configuration.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -587,10 +587,12 @@ private function getOtlpExportersOptionsNode(): ArrayNodeDefinition
587587
->values(array_map(fn (OtlpExporterCompressionEnum $format) => $format->value, OtlpExporterCompressionEnum::cases()))
588588
->end()
589589
->arrayNode('headers')
590-
->arrayPrototype()
591-
->children()
592-
->scalarNode('name')->isRequired()->cannotBeEmpty()->end()
593-
->scalarNode('value')->isRequired()->cannotBeEmpty()->end()
590+
->useAttributeAsKey('name')
591+
->normalizeKeys(false)
592+
->variablePrototype()
593+
->beforeNormalization()
594+
->ifArray()
595+
->then(static fn ($v) => array_values($v))
594596
->end()
595597
->end()
596598
->end()

tests/Unit/DependencyInjection/ConfigurationTest.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,7 @@ public function testReferenceConfiguration(): void
292292
headers:
293293
294294
# Prototype
295-
-
296-
name: ~ # Required
297-
value: ~ # Required
295+
name: ~
298296
timeout: 0.1
299297
retry: 100
300298
max: 3
@@ -331,9 +329,7 @@ public function testReferenceConfiguration(): void
331329
headers:
332330
333331
# Prototype
334-
-
335-
name: ~ # Required
336-
value: ~ # Required
332+
name: ~
337333
timeout: 0.1
338334
retry: 100
339335
max: 3
@@ -395,9 +391,7 @@ public function testReferenceConfiguration(): void
395391
headers:
396392
397393
# Prototype
398-
-
399-
name: ~ # Required
400-
value: ~ # Required
394+
name: ~
401395
timeout: 0.1
402396
retry: 100
403397
max: 3

tests/Unit/DependencyInjection/OpenTelemetryLogsExtensionTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,7 @@ public static function exporters(): \Generator
237237
'format' => 'json',
238238
'compression' => 'gzip',
239239
'headers' => [
240-
[
241-
'name' => 'X-Foo',
242-
'value' => 'Bar',
243-
],
240+
'X-Foo' => 'Bar',
244241
],
245242
'timeout' => 0.4,
246243
'retry' => 500,

tests/Unit/DependencyInjection/OpenTelemetryMetricsExtensionTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,7 @@ public static function exporters(): \Generator
205205
'format' => 'json',
206206
'compression' => 'gzip',
207207
'headers' => [
208-
[
209-
'name' => 'X-Foo',
210-
'value' => 'Bar',
211-
],
208+
'X-Foo' => 'Bar',
212209
],
213210
'timeout' => 0.4,
214211
'retry' => 500,

tests/Unit/DependencyInjection/OpenTelemetryTracesExtensionTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,7 @@ public static function exporters(): \Generator
215215
'format' => 'json',
216216
'compression' => 'gzip',
217217
'headers' => [
218-
[
219-
'name' => 'X-Foo',
220-
'value' => 'Bar',
221-
],
218+
'X-Foo' => 'Bar',
222219
],
223220
'timeout' => 0.4,
224221
'retry' => 500,

0 commit comments

Comments
 (0)