Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the MinMaxSumCount from cortex and datadog exporter #1554

Merged
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

- Change the `http-server-duration` instrument in `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp` to record milliseconds instead of microseconds match what is specified in the OpenTelemetry specification. (#1414, #1537)

### Removed

- Remove the MinMaxSumCount from cortex and datadog exporter. (#1554)

## [1.3.0/0.28.0] - 2021-12-10

### ⚠️ Notice ⚠️
Expand Down
7 changes: 3 additions & 4 deletions exporters/metric/cortex/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,11 @@ that instruments are mapped to aggregations as shown in the table below.
| ValueObserver | Histogram |

Although only the `Sum` and `Histogram` aggregations are currently being used, the
exporter supports 5 different aggregations:
exporter supports 4 different aggregations:
1. `Sum`
2. `LastValue`
3. `MinMaxSumCount`
4. `Distribution`
5. `Histogram`
3. `Distribution`
4. `Histogram`

## Error Handling
In general, errors are returned to the calling function / method. Eventually, errors make
Expand Down
43 changes: 0 additions & 43 deletions exporters/metric/cortex/cortex.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,6 @@ func (e *Exporter) ConvertToTimeSeries(res *resource.Resource, checkpointSet exp
return err
}
timeSeries = append(timeSeries, tSeries)
if minMaxSumCount, ok := agg.(aggregation.MinMaxSumCount); ok {
tSeries, err := convertFromMinMaxSumCount(edata, minMaxSumCount)
if err != nil {
return err
}
timeSeries = append(timeSeries, tSeries...)
}
} else if lastValue, ok := agg.(aggregation.LastValue); ok {
tSeries, err := convertFromLastValue(edata, lastValue)
if err != nil {
Expand Down Expand Up @@ -238,42 +231,6 @@ func convertFromLastValue(edata exportData, lastValue aggregation.LastValue) (pr
return tSeries, nil
}

// convertFromMinMaxSumCount returns 4 TimeSeries for the min, max, sum, and count from the mmsc aggregation
func convertFromMinMaxSumCount(edata exportData, minMaxSumCount aggregation.MinMaxSumCount) ([]prompb.TimeSeries, error) {
numberKind := edata.Descriptor().NumberKind()

// Convert Min
min, err := minMaxSumCount.Min()
if err != nil {
return nil, err
}
name := sanitize(edata.Descriptor().Name() + "_min")
minTimeSeries := createTimeSeries(edata, min, numberKind, attribute.String("__name__", name))

// Convert Max
max, err := minMaxSumCount.Max()
if err != nil {
return nil, err
}
name = sanitize(edata.Descriptor().Name() + "_max")
maxTimeSeries := createTimeSeries(edata, max, numberKind, attribute.String("__name__", name))

// Convert Count
count, err := minMaxSumCount.Count()
if err != nil {
return nil, err
}
name = sanitize(edata.Descriptor().Name() + "_count")
countTimeSeries := createTimeSeries(edata, number.NewInt64Number(int64(count)), number.Int64Kind, attribute.String("__name__", name))

// Return all timeSeries
tSeries := []prompb.TimeSeries{
minTimeSeries, maxTimeSeries, countTimeSeries,
}

return tSeries, nil
}

// convertFromHistogram returns len(histogram.Buckets) timeseries for a histogram aggregation
func convertFromHistogram(edata exportData, histogram aggregation.Histogram) ([]prompb.TimeSeries, error) {
var timeSeries []prompb.TimeSeries
Expand Down
6 changes: 0 additions & 6 deletions exporters/metric/cortex/cortex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,6 @@ func TestConvertToTimeSeries(t *testing.T) {
want: wantLastValueTimeSeries,
wantLength: 1,
},
{
name: "convertFromMinMaxSumCount",
input: getMMSCReader(t, 123.456, 876.543),
want: wantMMSCTimeSeries,
wantLength: 4,
},
{
name: "convertFromHistogram",
input: getHistogramReader(t),
Expand Down
88 changes: 0 additions & 88 deletions exporters/metric/cortex/testutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"go.opentelemetry.io/otel/sdk/export/metric/aggregation"
"go.opentelemetry.io/otel/sdk/metric/aggregator/histogram"
"go.opentelemetry.io/otel/sdk/metric/aggregator/lastvalue"
"go.opentelemetry.io/otel/sdk/metric/aggregator/minmaxsumcount"
"go.opentelemetry.io/otel/sdk/metric/aggregator/sum"
controller "go.opentelemetry.io/otel/sdk/metric/controller/basic"
processor "go.opentelemetry.io/otel/sdk/metric/processor/basic"
Expand All @@ -55,11 +54,6 @@ func (testAggregatorSelector) AggregatorFor(desc *sdkapi.Descriptor, aggPtrs ...
for i := range aggPtrs {
*aggPtrs[i] = &aggs[i]
}
case strings.HasSuffix(desc.Name(), "_mmsc"):
aggs := minmaxsumcount.New(len(aggPtrs), desc)
for i := range aggPtrs {
*aggPtrs[i] = &aggs[i]
}
case strings.HasSuffix(desc.Name(), "_lastvalue"):
aggs := lastvalue.New(len(aggPtrs))
for i := range aggPtrs {
Expand Down Expand Up @@ -115,21 +109,6 @@ func getLastValueReader(t *testing.T, values ...int64) export.InstrumentationLib
return cont
}

// getMMSCReader returns a checkpoint set with a minmaxsumcount aggregation record
func getMMSCReader(t *testing.T, values ...float64) export.InstrumentationLibraryReader {
ctx, meter, cont := testMeter(t)

histo := metric.Must(meter).NewFloat64Histogram("metric_mmsc")

for _, value := range values {
histo.Record(ctx, value)
}

require.NoError(t, cont.Collect(ctx))

return cont
}

// getHistogramReader returns a checkpoint set with a histogram aggregation record
func getHistogramReader(t *testing.T) export.InstrumentationLibraryReader {
ctx, meter, cont := testMeter(t)
Expand Down Expand Up @@ -186,73 +165,6 @@ var wantLastValueTimeSeries = []*prompb.TimeSeries{
},
}

var wantMMSCTimeSeries = []*prompb.TimeSeries{
{
Labels: []prompb.Label{
{
Name: "R",
Value: "V",
},
{
Name: "__name__",
Value: "metric_mmsc",
},
},
Samples: []prompb.Sample{{
Value: 999.999,
// Timestamp: this test verifies real timestamps
}},
},
{
Labels: []prompb.Label{
{
Name: "R",
Value: "V",
},
{
Name: "__name__",
Value: "metric_mmsc_min",
},
},
Samples: []prompb.Sample{{
Value: 123.456,
// Timestamp: this test verifies real timestamps
}},
},
{
Labels: []prompb.Label{
{
Name: "R",
Value: "V",
},
{
Name: "__name__",
Value: "metric_mmsc_max",
},
},
Samples: []prompb.Sample{{
Value: 876.543,
// Timestamp: this test verifies real timestamps
}},
},
{
Labels: []prompb.Label{
{
Name: "R",
Value: "V",
},
{
Name: "__name__",
Value: "metric_mmsc_count",
},
},
Samples: []prompb.Sample{{
Value: 2,
// Timestamp: this test verifies real timestamps
}},
},
}

var wantHistogramTimeSeries = []*prompb.TimeSeries{
{
Labels: []prompb.Label{
Expand Down
24 changes: 0 additions & 24 deletions exporters/metric/datadog/datadog.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,30 +123,6 @@ func (e *Exporter) Export(ctx context.Context, res *resource.Resource, ilr expor
return fmt.Errorf("error submitting %s point: %w", name, err)
}
}
case aggregation.MinMaxSumCount:
type record struct {
name string
f func() (number.Number, error)
}
recs := []record{
{
name: name + ".min",
f: agg.Min,
},
{
name: name + ".max",
f: agg.Max,
},
}
for _, rec := range recs {
val, err := rec.f()
if err != nil {
return fmt.Errorf("error getting MinMaxSumCount value for %s: %w", name, err)
}
if err := e.client.Gauge(rec.name, metricValue(r.Descriptor().NumberKind(), val), tags, rate); err != nil {
return fmt.Errorf("error submitting %s point: %w", name, err)
}
}
case aggregation.Sum:
val, err := agg.Sum()
if err != nil {
Expand Down
8 changes: 2 additions & 6 deletions exporters/metric/datadog/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"fmt"
"net"
"os"
"strings"
"time"

"github.com/DataDog/datadog-go/statsd"
Expand Down Expand Up @@ -90,10 +89,7 @@ func ExampleExporter() {
// specifics of OpenTelemetry aggregator calculations
// "max" is something that will always exist and always be the same
statLine := string(d)
if strings.HasPrefix(statLine, "myrecorder.max") {
fmt.Println(statLine)
return
}
fmt.Println(statLine)
case <-timedOutChan:
_, _ = fmt.Fprintln(os.Stderr, "Server timed out waiting for packets")
return
Expand All @@ -104,7 +100,7 @@ func ExampleExporter() {
}

// Output:
// myrecorder.max:100|g|#env:dev,l:1,service.name:ExampleExporter,telemetry.sdk.language:go,telemetry.sdk.name:opentelemetry,telemetry.sdk.version:1.2.0
// myrecorder:151|c|#env:dev,l:1,service.name:ExampleExporter,telemetry.sdk.language:go,telemetry.sdk.name:opentelemetry,telemetry.sdk.version:1.2.0
hanyuancheung marked this conversation as resolved.
Show resolved Hide resolved
//
}

Expand Down