Skip to content

Commit

Permalink
move dummy component providers to tests dir
Browse files Browse the repository at this point in the history
  • Loading branch information
brettmc committed Dec 17, 2024
1 parent b38bee9 commit a9649f5
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 11 deletions.
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
2 changes: 2 additions & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<UndefinedInterfaceMethod>
<errorLevel type="suppress">
<directory name="src/Config/SDK/ComponentProvider"/>
<directory name="tests/Integration/Config/ComponentProvider"/>
</errorLevel>
</UndefinedInterfaceMethod>
<PossiblyNullReference>
Expand All @@ -50,6 +51,7 @@
<MoreSpecificImplementedParamType>
<errorLevel type="suppress">
<directory name="src/Config/SDK/ComponentProvider"/>
<directory name="tests/Integration/Config/ComponentProvider"/>
</errorLevel>
</MoreSpecificImplementedParamType>
<InvalidDocblock>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ final class AggregationResolverExplicitBucketHistogram implements ComponentProvi
*/
public function createPlugin(array $properties, Context $context): DefaultAggregationProviderInterface
{
// TODO Implement proper aggregation providers (default, drop, explicit_bucket_histogram, last_value, sum) to handle advisory
return new class() implements DefaultAggregationProviderInterface {
use DefaultAggregationProviderTrait;
};
Expand All @@ -38,9 +37,11 @@ public function getConfig(ComponentProviderRegistry $registry): ArrayNodeDefinit
$node
->children()
->arrayNode('boundaries')
->prototype('scalar')->validate()->always(Validation::ensureNumber())->end()->end()
->prototype('scalar')
->validate()->always(Validation::ensureNumber())->end()
->end()
->end()

Check failure on line 43 in tests/Integration/Config/ComponentProvider/Metrics/AggregationResolverExplicitBucketHistogram.php

View workflow job for this annotation

GitHub Actions / php (8.1, false)

PossiblyNullReference

tests/Integration/Config/ComponentProvider/Metrics/AggregationResolverExplicitBucketHistogram.php:43:19: PossiblyNullReference: Cannot call method end on possibly null value (see https://psalm.dev/083)
->booleanNode('record_min_max')->defaultValue(false)->end()
->booleanNode('record_min_max')->defaultTrue()->end()
->end();

return $node;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@

namespace OpenTelemetry\Tests\Integration\Config\ComponentProvider\Metrics;

use OpenTelemetry\API\Behavior\LogsMessagesTrait;
use OpenTelemetry\Config\SDK\Configuration\ComponentProvider;
use OpenTelemetry\Config\SDK\Configuration\ComponentProviderRegistry;
use OpenTelemetry\Config\SDK\Configuration\Context;
use OpenTelemetry\Config\SDK\Configuration\Validation;
use OpenTelemetry\SDK\Metrics\MetricExporter\NoopMetricExporter;
use OpenTelemetry\SDK\Metrics\MetricExporterInterface;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;

Expand All @@ -33,7 +31,7 @@ final class MetricExporterPrometheus implements ComponentProvider
*/
public function createPlugin(array $properties, Context $context): MetricExporterInterface
{
return new class implements MetricExporterInterface {
return new class() implements MetricExporterInterface {

public function export(iterable $batch): bool
{
Expand Down Expand Up @@ -68,6 +66,7 @@ public function getConfig(ComponentProviderRegistry $registry): ArrayNodeDefinit
->end()
->end()
->end()
->end()
;

return $node;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@

namespace OpenTelemetry\Tests\Integration\Config\ComponentProvider\Metrics;

use OpenTelemetry\API\Behavior\LogsMessagesTrait;
use OpenTelemetry\Config\SDK\Configuration\ComponentPlugin;
use OpenTelemetry\Config\SDK\Configuration\ComponentProvider;
use OpenTelemetry\Config\SDK\Configuration\ComponentProviderRegistry;
use OpenTelemetry\Config\SDK\Configuration\Context;
use OpenTelemetry\SDK\Metrics\MetricExporterInterface;
use OpenTelemetry\SDK\Metrics\MetricReader\NoopReader;
use OpenTelemetry\SDK\Metrics\MetricReaderInterface;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;

Expand All @@ -27,7 +25,7 @@ final class MetricReaderPull implements ComponentProvider
*/
public function createPlugin(array $properties, Context $context): MetricReaderInterface
{
return new class implements MetricReaderInterface {
return new class() implements MetricReaderInterface {

public function collect(): bool
{
Expand All @@ -54,6 +52,7 @@ public function getConfig(ComponentProviderRegistry $registry): ArrayNodeDefinit
->append($registry->component('exporter', MetricExporterInterface::class)->isRequired())
->arrayNode('producers') //@todo
->variablePrototype()->end()
->end()

Check failure on line 55 in tests/Integration/Config/ComponentProvider/Metrics/MetricReaderPull.php

View workflow job for this annotation

GitHub Actions / php (8.1, false)

PossiblyNullReference

tests/Integration/Config/ComponentProvider/Metrics/MetricReaderPull.php:55:19: PossiblyNullReference: Cannot call method end on possibly null value (see https://psalm.dev/083)
->end()
;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class TextMapPropagatorOtTrace implements ComponentProvider
{
public function createPlugin(array $properties, Context $context): TextMapPropagatorInterface
{
return new class implements TextMapPropagatorInterface {
return new class() implements TextMapPropagatorInterface {

public function fields(): array
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class TextMapPropagatorXray implements ComponentProvider
{
public function createPlugin(array $properties, Context $context): TextMapPropagatorInterface
{
return new class implements TextMapPropagatorInterface {
return new class() implements TextMapPropagatorInterface {

public function fields(): array
{
Expand Down

0 comments on commit a9649f5

Please sign in to comment.