summaryrefslogtreecommitdiff
path: root/vendor/open-telemetry/sdk/Metrics/DefaultAggregationProviderTrait.php
blob: 37c5cb11079b7c3561b7fbe15e3db9a97c7f0ed0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php

declare(strict_types=1);

namespace OpenTelemetry\SDK\Metrics;

trait DefaultAggregationProviderTrait
{
    public function defaultAggregation($instrumentType): ?AggregationInterface
    {
        switch ($instrumentType) {
            case InstrumentType::COUNTER:
            case InstrumentType::ASYNCHRONOUS_COUNTER:
                return new Aggregation\SumAggregation(true);
            case InstrumentType::UP_DOWN_COUNTER:
            case InstrumentType::ASYNCHRONOUS_UP_DOWN_COUNTER:
                return new Aggregation\SumAggregation();
            case InstrumentType::HISTOGRAM:
                return new Aggregation\ExplicitBucketHistogramAggregation([0, 5, 10, 25, 50, 75, 100, 250, 500, 1000]);
            case InstrumentType::ASYNCHRONOUS_GAUGE:
                return new Aggregation\LastValueAggregation();
        }

        // @codeCoverageIgnoreStart
        return null;
        // @codeCoverageIgnoreEnd
    }
}