Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/Config/SDK/ComponentProvider/Logs/LogRecordExporterOtlp.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ final class LogRecordExporterOtlp implements ComponentProvider
* headers: array<string, string>,
* compression: 'gzip'|null,
* timeout: int<0, max>,
* retry: array{
* initial_delay: int,
* max_attempts: int
* }
* } $properties
*/
public function createPlugin(array $properties, Context $context): LogRecordExporterInterface
Expand All @@ -46,6 +50,8 @@ public function createPlugin(array $properties, Context $context): LogRecordExpo
headers: $properties['headers'],
compression: $properties['compression'],
timeout: $properties['timeout'],
retryDelay: $properties['retry']['initial_delay'],
maxRetries: $properties['retry']['max_attempts'],
cacert: $properties['certificate'],
cert: $properties['client_certificate'],
key: $properties['client_certificate'],
Expand All @@ -67,6 +73,16 @@ public function getConfig(ComponentProviderRegistry $registry): ArrayNodeDefinit
->end()
->enumNode('compression')->values(['gzip'])->defaultNull()->end()
->integerNode('timeout')->min(0)->defaultValue(10)->end()
->arrayNode('retry')
->children()
->integerNode('max_attempts')->min(0)->defaultValue(3)->end()
->integerNode('initial_delay')->min(0)->defaultValue(0)->end()
->end()
->end()
->end()
->beforeNormalization()
->ifTrue(fn ($data): bool => !array_key_exists('retry', $data))
->then(fn ($data): array => $data + ['retry' => []])
->end()
;

Expand Down
16 changes: 16 additions & 0 deletions src/Config/SDK/ComponentProvider/Metrics/MetricExporterOtlp.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ final class MetricExporterOtlp implements ComponentProvider
* headers: array<string, string>,
* compression: 'gzip'|null,
* timeout: int<0, max>,
* retry: array{
* initial_delay: int,
* max_attempts: int,
* },
* temporality_preference: 'cumulative'|'delta'|'lowmemory',
* default_histogram_aggregation: 'explicit_bucket_histogram',
* } $properties
Expand All @@ -55,6 +59,8 @@ public function createPlugin(array $properties, Context $context): MetricExporte
headers: $properties['headers'],
compression: $properties['compression'],
timeout: $properties['timeout'],
retryDelay: $properties['retry']['initial_delay'],
maxRetries: $properties['retry']['max_attempts'],
cacert: $properties['certificate'],
cert: $properties['client_certificate'],
key: $properties['client_certificate'],
Expand All @@ -76,6 +82,12 @@ public function getConfig(ComponentProviderRegistry $registry): ArrayNodeDefinit
->end()
->enumNode('compression')->values(['gzip'])->defaultNull()->validate()->always(Validation::ensureString())->end()->end()
->integerNode('timeout')->min(0)->defaultValue(10)->end()
->arrayNode('retry')
->children()
->integerNode('max_attempts')->min(0)->defaultValue(3)->end()
->integerNode('initial_delay')->min(0)->defaultValue(0)->end()
->end()
->end()
->enumNode('temporality_preference')
->values(['cumulative', 'delta', 'lowmemory'])
->defaultValue('cumulative')
Expand All @@ -85,6 +97,10 @@ public function getConfig(ComponentProviderRegistry $registry): ArrayNodeDefinit
->defaultValue('explicit_bucket_histogram')
->end()
->end()
->beforeNormalization()
->ifTrue(fn ($data): bool => !array_key_exists('retry', $data))
->then(fn ($data): array => $data + ['retry' => []])
->end()
;

return $node;
Expand Down
16 changes: 16 additions & 0 deletions src/Config/SDK/ComponentProvider/Trace/SpanExporterOtlp.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ final class SpanExporterOtlp implements ComponentProvider
* headers: array<string, string>,
* compression: 'gzip'|null,
* timeout: int<0, max>,
* retry: array{
* initial_delay: int,
* max_attempts: int
* }
* } $properties
*/
public function createPlugin(array $properties, Context $context): SpanExporterInterface
Expand All @@ -46,6 +50,8 @@ public function createPlugin(array $properties, Context $context): SpanExporterI
headers: $properties['headers'],
compression: $properties['compression'],
timeout: $properties['timeout'],
retryDelay: $properties['retry']['initial_delay'],
maxRetries: $properties['retry']['max_attempts'],
cacert: $properties['certificate'],
cert: $properties['client_certificate'],
key: $properties['client_certificate'],
Expand All @@ -67,6 +73,16 @@ public function getConfig(ComponentProviderRegistry $registry): ArrayNodeDefinit
->end()
->enumNode('compression')->values(['gzip'])->defaultNull()->end()
->integerNode('timeout')->min(0)->defaultValue(10)->end()
->arrayNode('retry')
->children()
->integerNode('max_attempts')->min(0)->defaultValue(3)->end()
->integerNode('initial_delay')->min(0)->defaultValue(0)->end()
->end()
->end()
->end()
->beforeNormalization()
->ifTrue(fn ($data): bool => !array_key_exists('retry', $data))
->then(fn ($data): array => $data + ['retry' => []])
->end()
;

Expand Down
16 changes: 16 additions & 0 deletions src/Config/SDK/ComponentProvider/Trace/SpanExporterZipkin.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ final class SpanExporterZipkin implements ComponentProvider
* @param array{
* endpoint: string,
* timeout: int<0, max>,
* retry: array{
* initial_delay: int,
* max_attempts: int
* }
* } $properties
*/
public function createPlugin(array $properties, Context $context): SpanExporterInterface
Expand All @@ -33,6 +37,8 @@ public function createPlugin(array $properties, Context $context): SpanExporterI
endpoint: $properties['endpoint'],
contentType: 'application/json',
timeout: $properties['timeout'],
retryDelay: $properties['retry']['initial_delay'],
maxRetries: $properties['retry']['max_attempts'],
));
}

Expand All @@ -43,6 +49,16 @@ public function getConfig(ComponentProviderRegistry $registry): ArrayNodeDefinit
->children()
->scalarNode('endpoint')->isRequired()->validate()->always(Validation::ensureString())->end()->end()
->integerNode('timeout')->min(0)->defaultValue(10)->end()
->arrayNode('retry')
->children()
->integerNode('max_attempts')->min(0)->defaultValue(3)->end()
->integerNode('initial_delay')->min(0)->defaultValue(0)->end()
->end()
->end()
->end()
->beforeNormalization()
->ifTrue(fn ($data): bool => !array_key_exists('retry', $data))
->then(fn ($data): array => $data + ['retry' => []])
->end()
;

Expand Down
1 change: 1 addition & 0 deletions tests/Integration/Config/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ public static function openTelemetryConfigurationDataProvider(): iterable
{
yield 'kitchen-sink' => [__DIR__ . '/configurations/kitchen-sink.yaml'];
yield 'anchors' => [__DIR__ . '/configurations/anchors.yaml'];
yield 'minimal' => [__DIR__ . '/configurations/minimal.yaml'];
}
}
3 changes: 3 additions & 0 deletions tests/Integration/Config/configurations/anchors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ exporters:
api-key: !!str 1234
compression: gzip
timeout: 10000
retry:
max_attempts: 5
initial_delay: 100

logger_provider:
processors:
Expand Down
12 changes: 12 additions & 0 deletions tests/Integration/Config/configurations/kitchen-sink.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ logger_provider:
#
# Environment variable: OTEL_EXPORTER_OTLP_TIMEOUT, OTEL_EXPORTER_OTLP_LOGS_TIMEOUT
timeout: 10000
retry:
max_attempts: 5
initial_delay: 100
# Configure log record limits. See also attribute_limits.
limits:
# Configure max log record attribute value size. Overrides attribute_limits.attribute_value_length_limit.
Expand Down Expand Up @@ -155,6 +158,9 @@ meter_provider:
#
# Environment variable: OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE
temporality_preference: delta
retry:
max_attempts: 5
initial_delay: 100
# Configure a periodic metric reader.
- periodic:
# Configure exporter.
Expand Down Expand Up @@ -257,6 +263,9 @@ tracer_provider:
#
# Environment variable: OTEL_EXPORTER_OTLP_TIMEOUT, OTEL_EXPORTER_OTLP_TRACES_TIMEOUT
timeout: 10000
retry:
max_attempts: 5
initial_delay: 100
# Configure a batch span processor.
- batch:
# Configure exporter.
Expand All @@ -273,6 +282,9 @@ tracer_provider:
#
# Environment variable: OTEL_EXPORTER_ZIPKIN_TIMEOUT
timeout: 10000
retry:
max_attempts: 5
initial_delay: 200
# Configure a simple span processor.
- simple:
# Configure exporter.
Expand Down
33 changes: 33 additions & 0 deletions tests/Integration/Config/configurations/minimal.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# minimal.yaml demonstrates only providing required attributes
file_format: "0.1"
logger_provider:
processors:
- batch:
exporter:
otlp:
protocol: http/protobuf
endpoint: http://localhost:4318
- simple:
exporter:
console: {}
meter_provider:
readers:
- periodic:
exporter:
otlp:
protocol: http/protobuf
endpoint: http://localhost:4318
tracer_provider:
processors:
- batch:
exporter:
otlp:
protocol: http/protobuf
endpoint: http://localhost:4318
- batch:
exporter:
zipkin:
endpoint: http://localhost:9411/api/v2/spans
- simple:
exporter:
console: {}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ final class SpanExporterOtlp implements ComponentProvider
* headers: array<string, string>,
* compression: 'gzip'|null,
* timeout: int<0, max>,
* retryDelay: int<0, max>,
* maxRetries: int<0, max>,
* } $properties
*/
public function createPlugin(array $properties, Context $context): SpanExporter
Expand All @@ -47,6 +49,12 @@ public function getConfig(ComponentProviderRegistry $registry): ArrayNodeDefinit
->end()
->enumNode('compression')->values(['gzip'])->defaultNull()->end()
->integerNode('timeout')->min(0)->defaultValue(10)->end()
->arrayNode('retry')
->children()
->integerNode('max_attempts')->min(0)->defaultValue(3)->end()
->integerNode('initial_delay')->min(0)->defaultValue(0)->end()
->end()
->end()
->end()
;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ tracer_provider:
#
# Environment variable: OTEL_EXPORTER_OTLP_TIMEOUT, OTEL_EXPORTER_OTLP_TRACES_TIMEOUT
timeout: 10000
retry:
max_attempts: 5
initial_delay: 100
# Configure a batch span processor.
- batch:
# Configure exporter.
Expand Down