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

Update ApplicationSignals log group name and adjust AWS service name #197

Merged
merged 2 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
26 changes: 13 additions & 13 deletions exporter/awsemfexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,35 +328,35 @@ func TestIsEnhancedContainerInsights(t *testing.T) {
assert.False(t, cfg.IsEnhancedContainerInsights())
}

func TestIsAppSignalsEnabled(t *testing.T) {
func TestIsApplicationSignalsEnabled(t *testing.T) {
tests := []struct {
name string
metricNameSpace string
logGroupName string
expectedResult bool
}{
{
"validAppSignalsEMF",
"AppSignals",
"/aws/appsignals/eks",
"validApplicationSignalsEMF",
"ApplicationSignals",
"/aws/application-signals/data",
true,
},
{
"invalidAppSignalsLogsGroup",
"AppSignals",
"/nonaws/appsignals/eks",
"invalidApplicationSignalsLogsGroup",
"ApplicationSignals",
"/nonaws/application-signals/eks",
false,
},
{
"invalidAppSignalsMetricNamespace",
"NonAppSignals",
"/aws/appsignals/eks",
"invalidApplicationSignalsMetricNamespace",
"NonApplicationSignals",
"/aws/application-signals/data",
false,
},
{
"invalidAppSignalsEMF",
"NonAppSignals",
"/nonaws/appsignals/eks",
"invalidApplicationSignalsEMF",
"NonApplicationSignals",
"/nonaws/application-signals/eks",
false,
},
{
Expand Down
23 changes: 9 additions & 14 deletions exporter/awsemfexporter/datapoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ type summaryMetricEntry struct {
}

// CalculateDeltaDatapoints retrieves the NumberDataPoint at the given index and performs rate/delta calculation if necessary.
func (dps numberDataPointSlice) CalculateDeltaDatapoints(i int, instrumentationScopeName string, _ bool, calculators *emfCalculators) ([]dataPoint, bool) {
func (dps numberDataPointSlice) CalculateDeltaDatapoints(i int, _ string, _ bool, calculators *emfCalculators) ([]dataPoint, bool) {
metric := dps.NumberDataPointSlice.At(i)
labels := createLabels(metric.Attributes(), instrumentationScopeName)
labels := createLabels(metric.Attributes())
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess we'll need to refactor it to make upstream happy on merging.

timestampMs := unixNanoToMilliseconds(metric.Timestamp())

var metricVal float64
Expand Down Expand Up @@ -157,9 +157,9 @@ func (dps numberDataPointSlice) IsStaleNaNInf(i int) (bool, pcommon.Map) {
}

// CalculateDeltaDatapoints retrieves the HistogramDataPoint at the given index.
func (dps histogramDataPointSlice) CalculateDeltaDatapoints(i int, instrumentationScopeName string, _ bool, calculators *emfCalculators) ([]dataPoint, bool) {
func (dps histogramDataPointSlice) CalculateDeltaDatapoints(i int, _ string, _ bool, calculators *emfCalculators) ([]dataPoint, bool) {
metric := dps.HistogramDataPointSlice.At(i)
labels := createLabels(metric.Attributes(), instrumentationScopeName)
labels := createLabels(metric.Attributes())
timestamp := unixNanoToMilliseconds(metric.Timestamp())

sum := metric.Sum()
Expand Down Expand Up @@ -213,7 +213,7 @@ func (dps histogramDataPointSlice) IsStaleNaNInf(i int) (bool, pcommon.Map) {
}

// CalculateDeltaDatapoints retrieves the ExponentialHistogramDataPoint at the given index.
func (dps exponentialHistogramDataPointSlice) CalculateDeltaDatapoints(idx int, instrumentationScopeName string, _ bool, _ *emfCalculators) ([]dataPoint, bool) {
func (dps exponentialHistogramDataPointSlice) CalculateDeltaDatapoints(idx int, _ string, _ bool, _ *emfCalculators) ([]dataPoint, bool) {
metric := dps.ExponentialHistogramDataPointSlice.At(idx)

scale := metric.Scale()
Expand Down Expand Up @@ -289,7 +289,7 @@ func (dps exponentialHistogramDataPointSlice) CalculateDeltaDatapoints(idx int,
Max: metric.Max(),
Min: metric.Min(),
},
labels: createLabels(metric.Attributes(), instrumentationScopeName),
labels: createLabels(metric.Attributes()),
timestampMs: unixNanoToMilliseconds(metric.Timestamp()),
}}, true
}
Expand All @@ -312,9 +312,9 @@ func (dps exponentialHistogramDataPointSlice) IsStaleNaNInf(i int) (bool, pcommo
}

// CalculateDeltaDatapoints retrieves the SummaryDataPoint at the given index and perform calculation with sum and count while retain the quantile value.
func (dps summaryDataPointSlice) CalculateDeltaDatapoints(i int, instrumentationScopeName string, detailedMetrics bool, calculators *emfCalculators) ([]dataPoint, bool) {
func (dps summaryDataPointSlice) CalculateDeltaDatapoints(i int, _ string, detailedMetrics bool, calculators *emfCalculators) ([]dataPoint, bool) {
metric := dps.SummaryDataPointSlice.At(i)
labels := createLabels(metric.Attributes(), instrumentationScopeName)
labels := createLabels(metric.Attributes())
timestampMs := unixNanoToMilliseconds(metric.Timestamp())

sum := metric.Sum()
Expand Down Expand Up @@ -391,18 +391,13 @@ func (dps summaryDataPointSlice) IsStaleNaNInf(i int) (bool, pcommon.Map) {

// createLabels converts OTel AttributesMap attributes to a map
// and optionally adds in the OTel instrumentation library name
func createLabels(attributes pcommon.Map, instrLibName string) map[string]string {
func createLabels(attributes pcommon.Map) map[string]string {
labels := make(map[string]string, attributes.Len()+1)
attributes.Range(func(k string, v pcommon.Value) bool {
labels[k] = v.AsString()
return true
})

// Add OTel instrumentation lib name as an additional label if it is defined
if instrLibName != "" {
labels[oTellibDimensionKey] = instrLibName
}

return labels
}

Expand Down
37 changes: 16 additions & 21 deletions exporter/awsemfexporter/datapoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ func TestCalculateDeltaDatapoints_NumberDataPointSlice(t *testing.T) {
expectedDatapoint: dataPoint{
name: "double",
value: 0.4,
labels: map[string]string{oTellibDimensionKey: instrLibName, "label1": "value1"},
labels: map[string]string{"label1": "value1"},
},
expectedRetained: retainInitialValueOfDeltaMetric,
},
Expand All @@ -454,7 +454,7 @@ func TestCalculateDeltaDatapoints_NumberDataPointSlice(t *testing.T) {
expectedDatapoint: dataPoint{
name: "double",
value: 0.4,
labels: map[string]string{oTellibDimensionKey: instrLibName, "label1": "value1"},
labels: map[string]string{"label1": "value1"},
},
expectedRetained: true,
},
Expand All @@ -466,7 +466,7 @@ func TestCalculateDeltaDatapoints_NumberDataPointSlice(t *testing.T) {
expectedDatapoint: dataPoint{
name: "double",
value: 0.5,
labels: map[string]string{oTellibDimensionKey: instrLibName, "label1": "value1"},
labels: map[string]string{"label1": "value1"},
},
expectedRetained: true,
},
Expand All @@ -479,7 +479,7 @@ func TestCalculateDeltaDatapoints_NumberDataPointSlice(t *testing.T) {
expectedDatapoint: dataPoint{
name: "int",
value: float64(-17),
labels: map[string]string{oTellibDimensionKey: instrLibName, "label1": "value1"},
labels: map[string]string{"label1": "value1"},
},
expectedRetained: retainInitialValueOfDeltaMetric,
},
Expand All @@ -491,7 +491,7 @@ func TestCalculateDeltaDatapoints_NumberDataPointSlice(t *testing.T) {
expectedDatapoint: dataPoint{
name: "int",
value: float64(18),
labels: map[string]string{oTellibDimensionKey: instrLibName, "label1": "value1"},
labels: map[string]string{"label1": "value1"},
},
expectedRetained: true,
},
Expand All @@ -503,7 +503,7 @@ func TestCalculateDeltaDatapoints_NumberDataPointSlice(t *testing.T) {
expectedDatapoint: dataPoint{
name: "int",
value: float64(10),
labels: map[string]string{oTellibDimensionKey: instrLibName, "label1": "value1"},
labels: map[string]string{"label1": "value1"},
},
expectedRetained: true,
},
Expand Down Expand Up @@ -567,7 +567,7 @@ func TestCalculateDeltaDatapoints_HistogramDataPointSlice(t *testing.T) {
expectedDatapoint: dataPoint{
name: "foo",
value: &cWMetricStats{Sum: 17.13, Count: 17, Min: 10, Max: 30},
labels: map[string]string{oTellibDimensionKey: instrLibName, "label1": "value1"},
labels: map[string]string{"label1": "value1"},
},
},
{
Expand All @@ -584,7 +584,7 @@ func TestCalculateDeltaDatapoints_HistogramDataPointSlice(t *testing.T) {
expectedDatapoint: dataPoint{
name: "foo",
value: &cWMetricStats{Sum: 17.13, Count: 17, Min: 0, Max: 0},
labels: map[string]string{oTellibDimensionKey: instrLibName, "label1": "value1"},
labels: map[string]string{"label1": "value1"},
},
},
{
Expand All @@ -602,7 +602,7 @@ func TestCalculateDeltaDatapoints_HistogramDataPointSlice(t *testing.T) {
expectedDatapoint: dataPoint{
name: "foo",
value: &cWMetricStats{Sum: 17.13, Count: 17, Min: 0, Max: 0},
labels: map[string]string{oTellibDimensionKey: instrLibName, "label1": "value1"},
labels: map[string]string{"label1": "value1"},
},
},
}
Expand Down Expand Up @@ -820,7 +820,7 @@ func TestCalculateDeltaDatapoints_HistogramDataPointSlice_Delta(t *testing.T) {
assert.Equal(t, dataPoint{
name: "foo",
value: &cWMetricStats{Sum: 0, Count: 0, Min: 10, Max: 30},
labels: map[string]string{oTellibDimensionKey: instrLibName, "label1": "value1"},
labels: map[string]string{"label1": "value1"},
}, dps[0])

histogramDatapointSlice.HistogramDataPointSlice.At(0).SetCount(uint64(27))
Expand All @@ -834,7 +834,7 @@ func TestCalculateDeltaDatapoints_HistogramDataPointSlice_Delta(t *testing.T) {
assert.Equal(t, dataPoint{
name: "foo",
value: &cWMetricStats{Sum: 10.14, Count: 10, Min: 5, Max: 40},
labels: map[string]string{oTellibDimensionKey: instrLibName, "label1": "value1"},
labels: map[string]string{"label1": "value1"},
}, dps[0])
}

Expand All @@ -861,7 +861,7 @@ func TestCalculateDeltaDatapoints_ExponentialHistogramDataPointSlice(t *testing.
expectedDatapoint: dataPoint{
name: "foo",
value: &cWMetricHistogram{Values: []float64{}, Counts: []float64{}, Sum: 17.13, Count: 17, Min: 10, Max: 30},
labels: map[string]string{oTellibDimensionKey: instrLibName, "label1": "value1"},
labels: map[string]string{"label1": "value1"},
},
},
{
Expand All @@ -878,7 +878,7 @@ func TestCalculateDeltaDatapoints_ExponentialHistogramDataPointSlice(t *testing.
expectedDatapoint: dataPoint{
name: "foo",
value: &cWMetricHistogram{Values: []float64{}, Counts: []float64{}, Sum: 17.13, Count: 17, Min: 0, Max: 0},
labels: map[string]string{oTellibDimensionKey: instrLibName, "label1": "value1"},
labels: map[string]string{"label1": "value1"},
},
},
{
Expand All @@ -895,7 +895,7 @@ func TestCalculateDeltaDatapoints_ExponentialHistogramDataPointSlice(t *testing.
expectedDatapoint: dataPoint{
name: "foo",
value: &cWMetricHistogram{Values: []float64{1.5, 3, 6, 0, -1.5, -3, -6}, Counts: []float64{1, 2, 3, 4, 1, 2, 3}},
labels: map[string]string{oTellibDimensionKey: instrLibName, "label1": "value1"},
labels: map[string]string{"label1": "value1"},
},
},
{
Expand All @@ -916,7 +916,7 @@ func TestCalculateDeltaDatapoints_ExponentialHistogramDataPointSlice(t *testing.
expectedDatapoint: dataPoint{
name: "foo",
value: &cWMetricHistogram{Values: []float64{0.625, 2.5, 10, 0, -0.625, -2.5, -10}, Counts: []float64{1, 2, 3, 4, 1, 2, 3}},
labels: map[string]string{oTellibDimensionKey: instrLibName, "label1": "value1", "label2": "value2"},
labels: map[string]string{"label1": "value1", "label2": "value2"},
},
},
}
Expand Down Expand Up @@ -1425,12 +1425,7 @@ func TestCreateLabels(t *testing.T) {
"c": "C",
}))

labels := createLabels(labelsMap, "")
assert.Equal(t, expectedLabels, labels)

// With isntrumentation library name
labels = createLabels(labelsMap, "cloudwatch-otel")
expectedLabels[oTellibDimensionKey] = "cloudwatch-otel"
labels := createLabels(labelsMap)
assert.Equal(t, expectedLabels, labels)
}

Expand Down
4 changes: 2 additions & 2 deletions exporter/awsemfexporter/emf_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ const (
outputDestinationStdout = "stdout"

// AppSignals EMF config
appSignalsMetricNamespace = "AppSignals"
appSignalsLogGroupNamePrefix = "/aws/appsignals/"
appSignalsMetricNamespace = "ApplicationSignals"
appSignalsLogGroupNamePrefix = "/aws/application-signals/"
)

type emfExporter struct {
Expand Down
22 changes: 9 additions & 13 deletions exporter/awsemfexporter/grouped_metric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestAddToGroupedMetric(t *testing.T) {
name: "Double gauge",
metric: generateTestGaugeMetric("foo", doubleValueType),
expectedMetricType: pmetric.MetricTypeGauge,
expectedLabels: map[string]string{oTellibDimensionKey: instrumentationLibName, "label1": "value1"},
expectedLabels: map[string]string{"label1": "value1"},
expectedMetricInfo: map[string]*metricInfo{
"foo": {
value: 0.1,
Expand All @@ -51,7 +51,7 @@ func TestAddToGroupedMetric(t *testing.T) {
name: "Int sum",
metric: generateTestSumMetric("foo", intValueType),
expectedMetricType: pmetric.MetricTypeSum,
expectedLabels: map[string]string{oTellibDimensionKey: instrumentationLibName, "label1": "value1"},
expectedLabels: map[string]string{"label1": "value1"},
expectedMetricInfo: map[string]*metricInfo{
"foo": {
value: float64(1),
Expand All @@ -63,7 +63,7 @@ func TestAddToGroupedMetric(t *testing.T) {
name: "Histogram",
metric: generateTestHistogramMetric("foo"),
expectedMetricType: pmetric.MetricTypeHistogram,
expectedLabels: map[string]string{oTellibDimensionKey: instrumentationLibName, "label1": "value1"},
expectedLabels: map[string]string{"label1": "value1"},
expectedMetricInfo: map[string]*metricInfo{
"foo": {
value: &cWMetricStats{
Expand All @@ -78,7 +78,7 @@ func TestAddToGroupedMetric(t *testing.T) {
name: "Summary",
metric: generateTestSummaryMetric("foo"),
expectedMetricType: pmetric.MetricTypeSummary,
expectedLabels: map[string]string{oTellibDimensionKey: instrumentationLibName, "label1": "value1"},
expectedLabels: map[string]string{"label1": "value1"},
expectedMetricInfo: map[string]*metricInfo{
"foo": {
value: &cWMetricStats{
Expand Down Expand Up @@ -120,7 +120,7 @@ func TestAddToGroupedMetric(t *testing.T) {
for _, v := range groupedMetrics {
assert.Equal(t, len(tc.expectedMetricInfo), len(v.metrics))
assert.Equal(t, tc.expectedMetricInfo, v.metrics)
assert.Equal(t, 2, len(v.labels))
assert.Equal(t, 1, len(v.labels))
assert.Equal(t, generateTestMetricMetadata(namespace, timestamp, logGroup, logStreamName, instrumentationLibName, tc.expectedMetricType), v.metadata)
assert.Equal(t, tc.expectedLabels, v.labels)
}
Expand Down Expand Up @@ -182,8 +182,7 @@ func TestAddToGroupedMetric(t *testing.T) {
assert.Fail(t, fmt.Sprintf("Unhandled metric %s not expected", metricName))
}
expectedLabels := map[string]string{
oTellibDimensionKey: "cloudwatch-otel",
"label1": "value1",
"label1": "value1",
}
assert.Equal(t, expectedLabels, group.labels)
}
Expand Down Expand Up @@ -254,8 +253,7 @@ func TestAddToGroupedMetric(t *testing.T) {
assert.Fail(t, fmt.Sprintf("Unhandled metric %s not expected", metricName))
}
expectedLabels := map[string]string{
oTellibDimensionKey: "cloudwatch-otel",
"label1": "value1",
"label1": "value1",
}
assert.Equal(t, expectedLabels, group.labels)
}
Expand Down Expand Up @@ -303,8 +301,7 @@ func TestAddToGroupedMetric(t *testing.T) {
}
assert.Equal(t, expectedMetrics, group.metrics)
expectedLabels := map[string]string{
oTellibDimensionKey: "cloudwatch-otel",
"label1": "value1",
"label1": "value1",
}
assert.Equal(t, expectedLabels, group.labels)

Expand Down Expand Up @@ -351,8 +348,7 @@ func TestAddToGroupedMetric(t *testing.T) {
assert.Equal(t, 1, len(groupedMetrics))

labels := map[string]string{
oTellibDimensionKey: instrumentationLibName,
"label1": "value1",
"label1": "value1",
}
// Test output warning logs
expectedLogs := []observer.LoggedEntry{
Expand Down
Loading
Loading