Skip to content

Commit

Permalink
[pdata] Rename pmetric.MetricDataPointFlags to pmetric.DataPointFlags (
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitryax authored Oct 11, 2022
1 parent 3f3ecd2 commit 6e554f2
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 31 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
- Deprecate `pcommon.NewValueString` in favor of `pcommon.NewValueStr` (#6209)
- Deprecate `pmetric.MetricAggregationTemporality` enum type in favor of `pmetric.AggregationTemporality` (#6249)
- Deprecate `confmap.Conf.UnmarshalExact` in favor of `confmap.Conf.Unmarshal(.., WithErrorUnused)` (#6231)
- Deprecate `pmetric.MetricDataPointFlags` favor of `pmetric.DataPointFlags` (#6259)
- Deprecate `ptrace.SpanStatus` favor of `ptrace.Status` (#6258)
- Deprecate `pmetric.[New]?Buckets` in favor of `pmetric.[New]?ExponentialHistogramDataPointBuckets` (#6261)
- Deprecate `plog.SeverityNumberUndefined` in favor of `plog.SeverityNumberUnspecified` (#6269)
Expand Down
2 changes: 1 addition & 1 deletion pdata/internal/cmd/pdatagen/internal/metrics_structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ var dataPointFlagsField = &primitiveTypedField{
fieldName: "Flags",
originFieldName: "Flags",
returnType: &primitiveType{
structName: "MetricDataPointFlags",
structName: "DataPointFlags",
rawType: "uint32",
defaultVal: "0",
testVal: "1",
Expand Down
24 changes: 12 additions & 12 deletions pdata/pmetric/generated_metrics.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions pdata/pmetric/generated_metrics_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 14 additions & 8 deletions pdata/pmetric/metric_data_point_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,30 @@ package pmetric // import "go.opentelemetry.io/collector/pdata/pmetric"

const noRecordValueMask = uint32(1)

var DefaultMetricDataPointFlags = MetricDataPointFlags(0)
var DefaultDataPointFlags = DataPointFlags(0)

// MetricDataPointFlags defines how a metric aggregator reports aggregated values.
// DataPointFlags defines how a metric aggregator reports aggregated values.
// It describes how those values relate to the time interval over which they are aggregated.
type MetricDataPointFlags uint32
type DataPointFlags uint32

// NoRecordedValue returns true if the MetricDataPointFlags contains the NoRecordedValue flag.
func (ms MetricDataPointFlags) NoRecordedValue() bool {
// NoRecordedValue returns true if the DataPointFlags contains the NoRecordedValue flag.
func (ms DataPointFlags) NoRecordedValue() bool {
return uint32(ms)&noRecordValueMask != 0
}

// WithNoRecordedValue returns a new MetricDataPointFlags, with the NoRecordedValue flag set to the given value.
func (ms MetricDataPointFlags) WithNoRecordedValue(b bool) MetricDataPointFlags {
// WithNoRecordedValue returns a new DataPointFlags, with the NoRecordedValue flag set to the given value.
func (ms DataPointFlags) WithNoRecordedValue(b bool) DataPointFlags {
orig := uint32(ms)
if b {
orig |= noRecordValueMask
} else {
orig &^= noRecordValueMask
}
return MetricDataPointFlags(orig)
return DataPointFlags(orig)
}

// Deprecated: [0.62.0] Use DefaultDataPointFlags instead.
var DefaultMetricDataPointFlags = DefaultDataPointFlags

// Deprecated: [0.62.0] Use DataPointFlags instead.
type MetricDataPointFlags = DataPointFlags
4 changes: 2 additions & 2 deletions pdata/pmetric/metric_data_point_flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
)

func TestLogRecordFlags(t *testing.T) {
flags := MetricDataPointFlags(1)
flags := DataPointFlags(1)
assert.True(t, flags.NoRecordedValue())
assert.EqualValues(t, uint32(1), flags)

Expand All @@ -35,7 +35,7 @@ func TestLogRecordFlags(t *testing.T) {
}

func TestDefaultLogRecordFlags(t *testing.T) {
flags := DefaultMetricDataPointFlags
flags := DefaultDataPointFlags
assert.False(t, flags.NoRecordedValue())
assert.EqualValues(t, uint32(0), flags)
}

0 comments on commit 6e554f2

Please sign in to comment.