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

[exporter/awsemf] Update ApplicationSignals log group name and adjust AWS service name #33798

Merged
Show file tree
Hide file tree
Changes from 5 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
27 changes: 27 additions & 0 deletions .chloggen/appsignals-and-awssdk-name-adjustments.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: awsemfexporter

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: AWS EMF Exporter to update ApplicationSignals log group name and namespace, adjust AWS service name, and remove OTelLib label from EMF log

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [33798]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [user]
26 changes: 13 additions & 13 deletions exporter/awsemfexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,35 +271,35 @@ func TestNoDimensionRollupFeatureGate(t *testing.T) {
_ = featuregate.GlobalRegistry().Set("awsemf.nodimrollupdefault", false)
}

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 @@ -110,9 +110,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())
timestampMs := unixNanoToMilliseconds(metric.Timestamp())

var metricVal float64
Expand Down Expand Up @@ -161,9 +161,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, _ *emfCalculators) ([]dataPoint, bool) {
func (dps histogramDataPointSlice) CalculateDeltaDatapoints(i int, _ string, _ bool, _ *emfCalculators) ([]dataPoint, bool) {
metric := dps.HistogramDataPointSlice.At(i)
labels := createLabels(metric.Attributes(), instrumentationScopeName)
labels := createLabels(metric.Attributes())
timestamp := unixNanoToMilliseconds(metric.Timestamp())

return []dataPoint{{
Expand Down Expand Up @@ -193,7 +193,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 @@ -269,7 +269,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 @@ -292,9 +292,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 @@ -371,18 +371,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
}

jj22ee marked this conversation as resolved.
Show resolved Hide resolved
return labels
}

Expand Down
33 changes: 14 additions & 19 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 @@ -817,7 +817,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 @@ -834,7 +834,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 @@ -851,7 +851,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 @@ -872,7 +872,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 @@ -1382,12 +1382,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 @@ -29,8 +29,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