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

AWSEMFExporter - Adding SummaryDataType, Remove MinMax from Histogram #1564

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
7da8b0f
Adding SummaryDataType, Remove MinMax from Histogram
shaochengwang Nov 13, 2020
9de5124
Not adding IntHistogram in this revision
shaochengwang Nov 13, 2020
cb4270e
Format the comments, replace tabs with spaces
shaochengwang Nov 13, 2020
0217d55
[awsemfexporter] Implement metric filtering and dimension setting (#1…
kohrapha Nov 13, 2020
b01cc16
Trace ID aware load-balancing exporter - 4/4 (#1542)
jpkrohling Nov 13, 2020
ed8eca5
Bump github.com/aws/aws-sdk-go in /internal/awsxray/testdata/sampleap…
dependabot[bot] Nov 13, 2020
14fcef3
Bump github.com/prometheus/common in /receiver/simpleprometheusreceiv…
dependabot[bot] Nov 13, 2020
84a94fc
Bump github.com/aliyun/aliyun-log-go-sdk (#1568)
dependabot[bot] Nov 13, 2020
255f46b
Bump github.com/honeycombio/libhoney-go in /exporter/honeycombexporte…
dependabot[bot] Nov 13, 2020
c0d37de
Bump github.com/aws/aws-sdk-go in /exporter/awsemfexporter (#1572)
dependabot[bot] Nov 13, 2020
49f8ad0
Bump github.com/google/go-cmp in /exporter/jaegerthrifthttpexporter (…
dependabot[bot] Nov 13, 2020
b2e5a3b
Bump github.com/aws/aws-sdk-go in /processor/resourcedetectionprocess…
dependabot[bot] Nov 13, 2020
631c24c
Bump github.com/google/go-cmp in /exporter/sentryexporter (#1581)
dependabot[bot] Nov 13, 2020
e344887
Bump github.com/aws/aws-sdk-go in /receiver/awsxrayreceiver (#1578)
dependabot[bot] Nov 13, 2020
18f87ac
Bump github.com/google/go-cmp in /processor/metricstransformprocessor…
dependabot[bot] Nov 13, 2020
fd04869
Bump github.com/aws/aws-sdk-go in /exporter/datadogexporter (#1575)
dependabot[bot] Nov 13, 2020
74c0de5
Bump github.com/prometheus/common in /receiver/prometheusexecreceiver…
dependabot[bot] Nov 13, 2020
0dbce50
Bump github.com/observiq/stanza in /receiver/stanzareceiver (#1573)
dependabot[bot] Nov 13, 2020
1571b78
Bump github.com/aws/aws-sdk-go in /exporter/awsxrayexporter (#1577)
dependabot[bot] Nov 13, 2020
31501b2
Bump github.com/google/go-cmp in /exporter/honeycombexporter (#1570)
dependabot[bot] Nov 13, 2020
56ee8c8
Fix version for carbonexporter, avoid dependabot upgrades like #1517 …
bogdandrutu Nov 13, 2020
497524c
Enable windows perf counters receiver (#1539)
james-bebbington Nov 13, 2020
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
Prev Previous commit
Next Next commit
Not adding IntHistogram in this revision
  • Loading branch information
shaochengwang committed Nov 13, 2020
commit 9de5124be6d94dbc6c7b17ddd385d4c17c322430
15 changes: 2 additions & 13 deletions exporter/awsemfexporter/metric_translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ type CWMetricStats struct {
// - pdata.DoubleDataPointSlice
// - pdata.IntHistogramDataPointSlice
// - pdata.DoubleHistogramDataPointSlice
// - pdata.DoubleSummaryDataPointSlice
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Align with previous comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Didn't see this in the IDE. I will replace all tabs with spaces :)

type DataPoints interface {
Len() int
At(int) DataPoint
Expand All @@ -92,6 +93,7 @@ type DataPoints interface {
// - pdata.DoubleDataPoint
// - pdata.IntHistogramDataPoint
// - pdata.DoubleHistogramDataPoint
// - pdata.DoubleSummaryDataPointSlice
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

type DataPoint interface {
IsNil() bool
LabelsMap() pdata.StringMap
Expand All @@ -104,9 +106,6 @@ type IntDataPointSlice struct {
type DoubleDataPointSlice struct {
pdata.DoubleDataPointSlice
}
type IntHistogramDataPointSlice struct {
pdata.IntHistogramDataPointSlice
}
type DoubleHistogramDataPointSlice struct {
pdata.DoubleHistogramDataPointSlice
}
Expand All @@ -120,9 +119,6 @@ func (dps IntDataPointSlice) At(i int) DataPoint {
func (dps DoubleDataPointSlice) At(i int) DataPoint {
return dps.DoubleDataPointSlice.At(i)
}
func (dps IntHistogramDataPointSlice) At(i int) DataPoint {
return dps.IntHistogramDataPointSlice.At(i)
}
func (dps DoubleHistogramDataPointSlice) At(i int) DataPoint {
return dps.DoubleHistogramDataPointSlice.At(i)
}
Expand Down Expand Up @@ -230,8 +226,6 @@ func getCWMetrics(metric *pdata.Metric, namespace string, instrumentationLibName
dps = IntDataPointSlice{metric.IntSum().DataPoints()}
case pdata.MetricDataTypeDoubleSum:
dps = DoubleDataPointSlice{metric.DoubleSum().DataPoints()}
case pdata.MetricDataTypeIntHistogram:
dps = IntHistogramDataPointSlice{metric.IntHistogram().DataPoints()}
case pdata.MetricDataTypeDoubleHistogram:
dps = DoubleHistogramDataPointSlice{metric.DoubleHistogram().DataPoints()}
case pdata.MetricDataTypeDoubleSummary:
Expand Down Expand Up @@ -290,11 +284,6 @@ func buildCWMetric(dp DataPoint, pmd *pdata.Metric, namespace string, metricSlic
if needsCalculateRate(pmd) {
metricVal = calculateRate(fields, metric.Value(), timestamp)
}
case pdata.IntHistogramDataPoint:
metricVal = &CWMetricStats{
Count: metric.Count(),
Sum: float64(metric.Sum()),
}
case pdata.DoubleHistogramDataPoint:
metricVal = &CWMetricStats{
Count: metric.Count(),
Expand Down
42 changes: 42 additions & 0 deletions exporter/awsemfexporter/metric_translator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import (
"go.opentelemetry.io/collector/translator/conventions"
"go.opentelemetry.io/collector/translator/internaldata"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"go.uber.org/zap/zaptest/observer"
)

// Asserts whether dimension sets are equal (i.e. has same sets of dimensions)
Expand Down Expand Up @@ -922,6 +924,37 @@ func TestGetCWMetrics(t *testing.T) {
})
}

t.Run("Unhandled metric type", func(t *testing.T) {
metric := pdata.NewMetric()
metric.InitEmpty()
metric.SetName("foo")
metric.SetUnit("Count")
metric.SetDataType(pdata.MetricDataTypeIntHistogram)

obs, logs := observer.New(zap.WarnLevel)
obsConfig := &Config{
DimensionRollupOption: "",
logger: zap.New(obs),
}

cwMetrics := getCWMetrics(&metric, namespace, instrumentationLibName, obsConfig)
assert.Nil(t, cwMetrics)

// Test output warning logs
expectedLogs := []observer.LoggedEntry{
{
Entry: zapcore.Entry{Level: zap.WarnLevel, Message: "Unhandled metric data type."},
Context: []zapcore.Field{
zap.String("DataType", "IntHistogram"),
zap.String("Name", "foo"),
zap.String("Unit", "Count"),
},
},
}
assert.Equal(t, 1, logs.Len())
assert.Equal(t, expectedLogs, logs.AllUntimed())
})

t.Run("Nil metric", func(t *testing.T) {
cwMetrics := getCWMetrics(nil, namespace, instrumentationLibName, config)
assert.Nil(t, cwMetrics)
Expand Down Expand Up @@ -1086,6 +1119,15 @@ func TestBuildCWMetric(t *testing.T) {
}
assert.Equal(t, expectedFields, cwMetric.Fields)
})

t.Run("Invalid datapoint type", func(t *testing.T) {
metric.SetDataType(pdata.MetricDataTypeIntGauge)
dp := pdata.NewIntHistogramDataPoint()
dp.InitEmpty()

cwMetric := buildCWMetric(dp, &metric, namespace, metricSlice, instrLibName, "")
assert.Nil(t, cwMetric)
})
}

func TestCreateDimensions(t *testing.T) {
Expand Down