| 1 |
// Copyright The OpenTelemetry Authors |
| 2 |
// SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
package pmetric // import "go.opentelemetry.io/collector/pdata/pmetric" |
| 5 |
|
| 6 |
const noRecordValueMask = uint32(1) |
| 7 |
|
| 8 |
var DefaultDataPointFlags = DataPointFlags(0) |
| 9 |
|
| 10 |
// DataPointFlags defines how a metric aggregator reports aggregated values. |
| 11 |
// It describes how those values relate to the time interval over which they are aggregated. |
| 12 |
type DataPointFlags uint32 |
| 13 |
|
| 14 |
// NoRecordedValue returns true if the DataPointFlags contains the NoRecordedValue flag. |
| 15 |
func (ms DataPointFlags) NoRecordedValue() bool { |
| 16 |
return uint32(ms)&noRecordValueMask != 0 |
| 17 |
} |
| 18 |
|
| 19 |
// WithNoRecordedValue returns a new DataPointFlags, with the NoRecordedValue flag set to the given value. |
| 20 |
func (ms DataPointFlags) WithNoRecordedValue(b bool) DataPointFlags { |
| 21 |
orig := uint32(ms) |
| 22 |
if b { |
| 23 |
orig |= noRecordValueMask |
| 24 |
} else { |
| 25 |
orig &^= noRecordValueMask |
| 26 |
} |
| 27 |
return DataPointFlags(orig) |
| 28 |
} |