Skip to content

Commit

Permalink
Merge branch '2.x' into composer-extra-registry
Browse files Browse the repository at this point in the history
  • Loading branch information
brettmc committed Jan 10, 2025
2 parents 0708e47 + a19455c commit 4159f2e
Show file tree
Hide file tree
Showing 114 changed files with 1,714 additions and 773 deletions.
8 changes: 7 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,13 @@
"OpenTelemetry\\Config\\SDK\\ComponentProvider\\Instrumentation\\General\\HttpConfigProvider",
"OpenTelemetry\\Config\\SDK\\ComponentProvider\\Instrumentation\\General\\PeerConfigProvider",

"OpenTelemetry\\Example\\ExampleConfigProvider"
"OpenTelemetry\\Example\\ExampleConfigProvider",

"OpenTelemetry\\Tests\\Integration\\Config\\ComponentProvider\\Metrics\\AggregationResolverExplicitBucketHistogram",
"OpenTelemetry\\Tests\\Integration\\Config\\ComponentProvider\\Metrics\\MetricExporterPrometheus",
"OpenTelemetry\\Tests\\Integration\\Config\\ComponentProvider\\Metrics\\MetricReaderPull",
"OpenTelemetry\\Tests\\Integration\\Config\\ComponentProvider\\Propagator\\TextMapPropagatorXray",
"OpenTelemetry\\Tests\\Integration\\Config\\ComponentProvider\\Propagator\\TextMapPropagatorOtTrace"
],
"OpenTelemetry\\API\\Instrumentation\\AutoInstrumentation\\HookManagerInterface": [
"OpenTelemetry\\API\\Instrumentation\\AutoInstrumentation\\ExtensionHookManager"
Expand Down
8 changes: 7 additions & 1 deletion examples/instrumentation/otel-sdk.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
file_format: '0.3'

propagator:
composite: []

tracer_provider:
processors:
- simple:
exporter:
console: {}
console:
sampler:
always_on:

instrumentation:
general:
php:
example_instrumentation:
span_name: ${EXAMPLE_INSTRUMENTATION_SPAN_NAME:-example span}
8 changes: 4 additions & 4 deletions examples/load_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ tracer_provider:
sampler:
parent_based:
root:
always_on: {}
always_on:
processors:
- simple:
exporter:
console: {}
console:
- batch:
exporter:
otlp: *otlp-exporter
meter_provider:
readers:
- periodic:
exporter:
console: {}
console:
- periodic:
exporter:
otlp:
Expand All @@ -40,7 +40,7 @@ logger_provider:
processors:
- simple:
exporter:
console: {}
console:
- batch:
exporter:
otlp: *otlp-exporter
9 changes: 5 additions & 4 deletions examples/src/ExampleConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use OpenTelemetry\Config\SDK\Configuration\Context;
use OpenTelemetry\Config\SDK\Configuration\Validation;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\NodeBuilder;

/**
* @implements ComponentProvider<InstrumentationConfiguration>
Expand All @@ -34,16 +35,16 @@ public function createPlugin(array $properties, Context $context): Instrumentati
/**
* @psalm-suppress UndefinedInterfaceMethod,PossiblyNullReference
*/
public function getConfig(ComponentProviderRegistry $registry): ArrayNodeDefinition
public function getConfig(ComponentProviderRegistry $registry, NodeBuilder $builder): ArrayNodeDefinition
{
$root = new ArrayNodeDefinition('example_instrumentation');
$root
$node = $builder->arrayNode('example_instrumentation');
$node
->children()
->scalarNode('span_name')->isRequired()->validate()->always(Validation::ensureString())->end()->end()
->end()
->canBeDisabled()
;

return $root;
return $node;
}
}
1 change: 1 addition & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ parameters:
message: "#Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeParentInterface::.*#"
paths:
- src/Config/SDK
- tests/Integration/Config
-
message: "#Cannot call method .* on null#"
paths:
Expand Down
23 changes: 23 additions & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,48 @@
<directory name="./examples"/>
</errorLevel>
</ArgumentTypeCoercion>
<InvalidArgument>
<errorLevel type="suppress">
<directory name="src/Config/SDK/Configuration/Internal"/>
</errorLevel>
</InvalidArgument>
<UndefinedInterfaceMethod>
<errorLevel type="suppress">
<directory name="src/Config/SDK/ComponentProvider"/>
<directory name="tests/Integration/Config/ComponentProvider"/>
</errorLevel>
</UndefinedInterfaceMethod>
<PossiblyInvalidArgument>
<errorLevel type="suppress">
<directory name="src/Config/SDK/Configuration"/>
</errorLevel>
</PossiblyInvalidArgument>
<PossiblyNullReference>
<errorLevel type="suppress">
<directory name="src/Config/SDK/ComponentProvider"/>
<directory name="tests/Integration/Config/ComponentProvider"/>
</errorLevel>
</PossiblyNullReference>
<MoreSpecificImplementedParamType>
<errorLevel type="suppress">
<directory name="src/Config/SDK/ComponentProvider"/>
<directory name="tests/Integration/Config/ComponentProvider"/>
</errorLevel>
</MoreSpecificImplementedParamType>
<InvalidDocblock>
<errorLevel type="suppress">
<directory name="src/Config/SDK/ComponentProvider"/>
</errorLevel>
</InvalidDocblock>
<NonInvariantDocblockPropertyType>
<errorLevel type="suppress">
<directory name="src/Config/SDK/Configuration/Internal"/>
</errorLevel>
</NonInvariantDocblockPropertyType>
<NonInvariantPropertyType>
<errorLevel type="suppress">
<directory name="src/Config/SDK/Configuration/Internal"/>
</errorLevel>
</NonInvariantPropertyType>
</issueHandlers>
</psalm>
2 changes: 1 addition & 1 deletion src/API/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"require": {
"php": "^8.2",
"open-telemetry/context": "^1.0",
"open-telemetry/context": "^1.0|^2.0",
"psr/log": "^1.1|^2.0|^3.0"
},
"conflict": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use OpenTelemetry\Config\SDK\Configuration\ComponentProviderRegistry;
use OpenTelemetry\Config\SDK\Configuration\Context;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\NodeBuilder;

/**
* @implements ComponentProvider<GeneralInstrumentationConfiguration>
Expand All @@ -21,22 +22,22 @@ public function createPlugin(array $properties, Context $context): GeneralInstru
return new HttpConfig($properties);
}

public function getConfig(ComponentProviderRegistry $registry): ArrayNodeDefinition
public function getConfig(ComponentProviderRegistry $registry, NodeBuilder $builder): ArrayNodeDefinition
{
$node = new ArrayNodeDefinition('http');
$node = $builder->arrayNode('http');
$node
->children()
->append($this->capturedHeaders('client'))
->append($this->capturedHeaders('server'))
->append($this->capturedHeaders('client', $builder))
->append($this->capturedHeaders('server', $builder))
->end()
;

return $node;
}

private function capturedHeaders(string $name): ArrayNodeDefinition
private function capturedHeaders(string $name, NodeBuilder $builder): ArrayNodeDefinition
{
$node = new ArrayNodeDefinition($name);
$node = $builder->arrayNode($name);
$node
->children()
->arrayNode('request_captured_headers')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use OpenTelemetry\Config\SDK\Configuration\ComponentProviderRegistry;
use OpenTelemetry\Config\SDK\Configuration\Context;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\NodeBuilder;

/**
* @implements ComponentProvider<GeneralInstrumentationConfiguration>
Expand All @@ -21,9 +22,9 @@ public function createPlugin(array $properties, Context $context): GeneralInstru
return new PeerConfig($properties);
}

public function getConfig(ComponentProviderRegistry $registry): ArrayNodeDefinition
public function getConfig(ComponentProviderRegistry $registry, NodeBuilder $builder): ArrayNodeDefinition
{
$node = new ArrayNodeDefinition('peer');
$node = $builder->arrayNode('peer');
$node
->children()
->arrayNode('service_mapping')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use OpenTelemetry\Config\SDK\Configuration\ComponentProviderRegistry;
use OpenTelemetry\Config\SDK\Configuration\Context;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\NodeBuilder;

/**
* @internal
Expand All @@ -24,7 +25,7 @@ class InstrumentationConfigurationRegistry implements ComponentProvider
* @param array{
* instrumentation: array{
* php: list<ComponentPlugin<InstrumentationConfiguration>>,
* general: list<ComponentPlugin<InstrumentationConfiguration>>
* general: list<ComponentPlugin<GeneralInstrumentationConfiguration>>
* }
* } $properties
*/
Expand All @@ -43,18 +44,16 @@ public function createPlugin(array $properties, Context $context): Configuration
return $configurationRegistry;
}

public function getConfig(ComponentProviderRegistry $registry): ArrayNodeDefinition
public function getConfig(ComponentProviderRegistry $registry, NodeBuilder $builder): ArrayNodeDefinition
{
$root = new ArrayNodeDefinition('open_telemetry');
$root = $builder->arrayNode('open_telemetry');
$root
->ignoreExtraKeys()
->children()
->arrayNode('instrumentation')
->ignoreExtraKeys()
->children()
->append($registry->componentList('php', InstrumentationConfiguration::class))
->append($registry->componentList('general', GeneralInstrumentationConfiguration::class))
->end()
->append($registry->componentMap('php', InstrumentationConfiguration::class))
->append($registry->componentMap('general', GeneralInstrumentationConfiguration::class))
->end()
->end()
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use OpenTelemetry\SDK\Logs\Exporter\ConsoleExporter;
use OpenTelemetry\SDK\Logs\LogRecordExporterInterface;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\NodeBuilder;

/**
* @implements ComponentProvider<LogRecordExporterInterface>
Expand All @@ -28,8 +29,8 @@ public function createPlugin(array $properties, Context $context): LogRecordExpo
));
}

public function getConfig(ComponentProviderRegistry $registry): ArrayNodeDefinition
public function getConfig(ComponentProviderRegistry $registry, NodeBuilder $builder): ArrayNodeDefinition
{
return new ArrayNodeDefinition('console');
return $builder->arrayNode('console');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use OpenTelemetry\SDK\Common\Services\Loader;
use OpenTelemetry\SDK\Logs\LogRecordExporterInterface;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\NodeBuilder;

/**
* @implements ComponentProvider<LogRecordExporterInterface>
Expand All @@ -35,6 +36,7 @@ final class LogRecordExporterOtlp implements ComponentProvider
* headers_list: ?string,
* compression: 'gzip'|null,
* timeout: int<0, max>,
* insecure: ?bool,
* } $properties
*/
public function createPlugin(array $properties, Context $context): LogRecordExporterInterface
Expand All @@ -55,9 +57,9 @@ public function createPlugin(array $properties, Context $context): LogRecordExpo
));
}

public function getConfig(ComponentProviderRegistry $registry): ArrayNodeDefinition
public function getConfig(ComponentProviderRegistry $registry, NodeBuilder $builder): ArrayNodeDefinition
{
$node = new ArrayNodeDefinition('otlp');
$node = $builder->arrayNode('otlp');
$node
->children()
->enumNode('protocol')->isRequired()->values(['http/protobuf', 'http/json', 'grpc'])->end()
Expand All @@ -76,6 +78,7 @@ public function getConfig(ComponentProviderRegistry $registry): ArrayNodeDefinit
->scalarNode('headers_list')->defaultNull()->validate()->always(Validation::ensureString())->end()->end()
->enumNode('compression')->values(['gzip'])->defaultNull()->end()
->integerNode('timeout')->min(0)->defaultValue(10)->end()
->booleanNode('insecure')->defaultNull()->end()
->end()
;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use OpenTelemetry\SDK\Logs\LogRecordProcessorInterface;
use OpenTelemetry\SDK\Logs\Processor\BatchLogRecordProcessor;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\NodeBuilder;

/**
* @implements ComponentProvider<LogRecordProcessorInterface>
Expand Down Expand Up @@ -41,9 +42,9 @@ public function createPlugin(array $properties, Context $context): LogRecordProc
);
}

public function getConfig(ComponentProviderRegistry $registry): ArrayNodeDefinition
public function getConfig(ComponentProviderRegistry $registry, NodeBuilder $builder): ArrayNodeDefinition
{
$node = new ArrayNodeDefinition('batch');
$node = $builder->arrayNode('batch');
$node
->children()
->integerNode('schedule_delay')->min(0)->defaultValue(5000)->end()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use OpenTelemetry\SDK\Logs\LogRecordProcessorInterface;
use OpenTelemetry\SDK\Logs\Processor\SimpleLogRecordProcessor;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\NodeBuilder;

/**
* @implements ComponentProvider<LogRecordProcessorInterface>
Expand All @@ -30,9 +31,9 @@ public function createPlugin(array $properties, Context $context): LogRecordProc
);
}

public function getConfig(ComponentProviderRegistry $registry): ArrayNodeDefinition
public function getConfig(ComponentProviderRegistry $registry, NodeBuilder $builder): ArrayNodeDefinition
{
$node = new ArrayNodeDefinition('simple');
$node = $builder->arrayNode('simple');
$node
->children()
->append($registry->component('exporter', LogRecordExporterInterface::class)->isRequired())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use OpenTelemetry\SDK\Metrics\DefaultAggregationProviderInterface;
use OpenTelemetry\SDK\Metrics\DefaultAggregationProviderTrait;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\NodeBuilder;

/**
* @implements ComponentProvider<DefaultAggregationProviderInterface>
Expand All @@ -27,8 +28,8 @@ public function createPlugin(array $properties, Context $context): DefaultAggreg
};
}

public function getConfig(ComponentProviderRegistry $registry): ArrayNodeDefinition
public function getConfig(ComponentProviderRegistry $registry, NodeBuilder $builder): ArrayNodeDefinition
{
return new ArrayNodeDefinition('default');
return $builder->arrayNode('default');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use OpenTelemetry\SDK\Metrics\MetricExporter\ConsoleMetricExporter;
use OpenTelemetry\SDK\Metrics\MetricExporterInterface;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\NodeBuilder;

/**
* @implements ComponentProvider<MetricExporterInterface>
Expand All @@ -24,8 +25,8 @@ public function createPlugin(array $properties, Context $context): MetricExporte
return new ConsoleMetricExporter();
}

public function getConfig(ComponentProviderRegistry $registry): ArrayNodeDefinition
public function getConfig(ComponentProviderRegistry $registry, NodeBuilder $builder): ArrayNodeDefinition
{
return new ArrayNodeDefinition('console');
return $builder->arrayNode('console');
}
}
Loading

0 comments on commit 4159f2e

Please sign in to comment.