class LastValueAggregation
@implements AggregationInterface<LastValueSummary>
Hierarchy
- class \OpenTelemetry\SDK\Metrics\Aggregation\LastValueAggregation implements \OpenTelemetry\SDK\Metrics\AggregationInterface
Expanded class hierarchy of LastValueAggregation
File
-
vendor/
open-telemetry/ sdk/ Metrics/ Aggregation/ LastValueAggregation.php, line 15
Namespace
OpenTelemetry\SDK\Metrics\AggregationView source
final class LastValueAggregation implements AggregationInterface {
public function initialize() : LastValueSummary {
return new LastValueSummary(null, 0);
}
/**
* @param LastValueSummary $summary
*/
public function record($summary, $value, AttributesInterface $attributes, ContextInterface $context, int $timestamp) : void {
if ($summary->value === null || $timestamp >= $summary->timestamp) {
$summary->value = $value;
$summary->timestamp = $timestamp;
}
}
/**
* @param LastValueSummary $left
* @param LastValueSummary $right
*/
public function merge($left, $right) : LastValueSummary {
return $right->timestamp >= $left->timestamp ? $right : $left;
}
/**
* @param LastValueSummary $left
* @param LastValueSummary $right
*/
public function diff($left, $right) : LastValueSummary {
return $right->timestamp >= $left->timestamp ? $right : $left;
}
/**
* @param array<LastValueSummary> $summaries
*/
public function toData(array $attributes, array $summaries, array $exemplars, int $startTimestamp, int $timestamp, $temporality) : Data\Gauge {
$dataPoints = [];
foreach ($attributes as $key => $dataPointAttributes) {
if ($summaries[$key]->value === null) {
continue;
}
$dataPoints[] = new Data\NumberDataPoint($summaries[$key]->value, $dataPointAttributes, $startTimestamp, $timestamp, $exemplars[$key] ?? []);
}
return new Data\Gauge($dataPoints);
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
LastValueAggregation::diff | public | function | Overrides AggregationInterface::diff | |
LastValueAggregation::initialize | public | function | @psalm-return T | Overrides AggregationInterface::initialize |
LastValueAggregation::merge | public | function | Overrides AggregationInterface::merge | |
LastValueAggregation::record | public | function | Overrides AggregationInterface::record | |
LastValueAggregation::toData | public | function | Overrides AggregationInterface::toData |