mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-10 21:47:13 +08:00
vendor: update buildkit to v0.18.0-rc1
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
87
vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/aggregate.go
generated
vendored
87
vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/aggregate.go
generated
vendored
@ -1,16 +1,5 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package aggregate // import "go.opentelemetry.io/otel/sdk/metric/internal/aggregate"
|
||||
|
||||
@ -19,6 +8,7 @@ import (
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/sdk/metric/internal/exemplar"
|
||||
"go.opentelemetry.io/otel/sdk/metric/metricdata"
|
||||
)
|
||||
|
||||
@ -44,42 +34,73 @@ type Builder[N int64 | float64] struct {
|
||||
// Filter is the attribute filter the aggregate function will use on the
|
||||
// input of measurements.
|
||||
Filter attribute.Filter
|
||||
// ReservoirFunc is the factory function used by aggregate functions to
|
||||
// create new exemplar reservoirs for a new seen attribute set.
|
||||
//
|
||||
// If this is not provided a default factory function that returns an
|
||||
// exemplar.Drop reservoir will be used.
|
||||
ReservoirFunc func() exemplar.FilteredReservoir[N]
|
||||
// AggregationLimit is the cardinality limit of measurement attributes. Any
|
||||
// measurement for new attributes once the limit has been reached will be
|
||||
// aggregated into a single aggregate for the "otel.metric.overflow"
|
||||
// attribute.
|
||||
//
|
||||
// If AggregationLimit is less than or equal to zero there will not be an
|
||||
// aggregation limit imposed (i.e. unlimited attribute sets).
|
||||
AggregationLimit int
|
||||
}
|
||||
|
||||
func (b Builder[N]) filter(f Measure[N]) Measure[N] {
|
||||
func (b Builder[N]) resFunc() func() exemplar.FilteredReservoir[N] {
|
||||
if b.ReservoirFunc != nil {
|
||||
return b.ReservoirFunc
|
||||
}
|
||||
|
||||
return exemplar.Drop
|
||||
}
|
||||
|
||||
type fltrMeasure[N int64 | float64] func(ctx context.Context, value N, fltrAttr attribute.Set, droppedAttr []attribute.KeyValue)
|
||||
|
||||
func (b Builder[N]) filter(f fltrMeasure[N]) Measure[N] {
|
||||
if b.Filter != nil {
|
||||
fltr := b.Filter // Copy to make it immutable after assignment.
|
||||
return func(ctx context.Context, n N, a attribute.Set) {
|
||||
fAttr, _ := a.Filter(fltr)
|
||||
f(ctx, n, fAttr)
|
||||
fAttr, dropped := a.Filter(fltr)
|
||||
f(ctx, n, fAttr, dropped)
|
||||
}
|
||||
}
|
||||
return f
|
||||
return func(ctx context.Context, n N, a attribute.Set) {
|
||||
f(ctx, n, a, nil)
|
||||
}
|
||||
}
|
||||
|
||||
// LastValue returns a last-value aggregate function input and output.
|
||||
//
|
||||
// The Builder.Temporality is ignored and delta is use always.
|
||||
func (b Builder[N]) LastValue() (Measure[N], ComputeAggregation) {
|
||||
// Delta temporality is the only temporality that makes semantic sense for
|
||||
// a last-value aggregate.
|
||||
lv := newLastValue[N]()
|
||||
lv := newLastValue[N](b.AggregationLimit, b.resFunc())
|
||||
switch b.Temporality {
|
||||
case metricdata.DeltaTemporality:
|
||||
return b.filter(lv.measure), lv.delta
|
||||
default:
|
||||
return b.filter(lv.measure), lv.cumulative
|
||||
}
|
||||
}
|
||||
|
||||
return b.filter(lv.measure), func(dest *metricdata.Aggregation) int {
|
||||
// Ignore if dest is not a metricdata.Gauge. The chance for memory
|
||||
// reuse of the DataPoints is missed (better luck next time).
|
||||
gData, _ := (*dest).(metricdata.Gauge[N])
|
||||
lv.computeAggregation(&gData.DataPoints)
|
||||
*dest = gData
|
||||
|
||||
return len(gData.DataPoints)
|
||||
// PrecomputedLastValue returns a last-value aggregate function input and
|
||||
// output. The aggregation returned from the returned ComputeAggregation
|
||||
// function will always only return values from the previous collection cycle.
|
||||
func (b Builder[N]) PrecomputedLastValue() (Measure[N], ComputeAggregation) {
|
||||
lv := newPrecomputedLastValue[N](b.AggregationLimit, b.resFunc())
|
||||
switch b.Temporality {
|
||||
case metricdata.DeltaTemporality:
|
||||
return b.filter(lv.measure), lv.delta
|
||||
default:
|
||||
return b.filter(lv.measure), lv.cumulative
|
||||
}
|
||||
}
|
||||
|
||||
// PrecomputedSum returns a sum aggregate function input and output. The
|
||||
// arguments passed to the input are expected to be the precomputed sum values.
|
||||
func (b Builder[N]) PrecomputedSum(monotonic bool) (Measure[N], ComputeAggregation) {
|
||||
s := newPrecomputedSum[N](monotonic)
|
||||
s := newPrecomputedSum[N](monotonic, b.AggregationLimit, b.resFunc())
|
||||
switch b.Temporality {
|
||||
case metricdata.DeltaTemporality:
|
||||
return b.filter(s.measure), s.delta
|
||||
@ -90,7 +111,7 @@ func (b Builder[N]) PrecomputedSum(monotonic bool) (Measure[N], ComputeAggregati
|
||||
|
||||
// Sum returns a sum aggregate function input and output.
|
||||
func (b Builder[N]) Sum(monotonic bool) (Measure[N], ComputeAggregation) {
|
||||
s := newSum[N](monotonic)
|
||||
s := newSum[N](monotonic, b.AggregationLimit, b.resFunc())
|
||||
switch b.Temporality {
|
||||
case metricdata.DeltaTemporality:
|
||||
return b.filter(s.measure), s.delta
|
||||
@ -102,7 +123,7 @@ func (b Builder[N]) Sum(monotonic bool) (Measure[N], ComputeAggregation) {
|
||||
// ExplicitBucketHistogram returns a histogram aggregate function input and
|
||||
// output.
|
||||
func (b Builder[N]) ExplicitBucketHistogram(boundaries []float64, noMinMax, noSum bool) (Measure[N], ComputeAggregation) {
|
||||
h := newHistogram[N](boundaries, noMinMax, noSum)
|
||||
h := newHistogram[N](boundaries, noMinMax, noSum, b.AggregationLimit, b.resFunc())
|
||||
switch b.Temporality {
|
||||
case metricdata.DeltaTemporality:
|
||||
return b.filter(h.measure), h.delta
|
||||
@ -114,7 +135,7 @@ func (b Builder[N]) ExplicitBucketHistogram(boundaries []float64, noMinMax, noSu
|
||||
// ExponentialBucketHistogram returns a histogram aggregate function input and
|
||||
// output.
|
||||
func (b Builder[N]) ExponentialBucketHistogram(maxSize, maxScale int32, noMinMax, noSum bool) (Measure[N], ComputeAggregation) {
|
||||
h := newExponentialHistogram[N](maxSize, maxScale, noMinMax, noSum)
|
||||
h := newExponentialHistogram[N](maxSize, maxScale, noMinMax, noSum, b.AggregationLimit, b.resFunc())
|
||||
switch b.Temporality {
|
||||
case metricdata.DeltaTemporality:
|
||||
return b.filter(h.measure), h.delta
|
||||
|
Reference in New Issue
Block a user