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] Add feature gate for default dimension rollup #24274

Merged
merged 21 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
793133c
Add feature gate for default dimension rollup
bryan-aguilar Jul 14, 2023
df78300
Update readme for nodimrollup feature gate
bryan-aguilar Jul 14, 2023
f92bfc3
Add log line warning
bryan-aguilar Jul 14, 2023
9ca1f37
Fix unit test
bryan-aguilar Jul 14, 2023
d1c6031
Update exporter/awsemfexporter/emf_exporter.go
bryan-aguilar Jul 17, 2023
77c1716
Update exporter/awsemfexporter/emf_exporter_test.go
bryan-aguilar Jul 17, 2023
9f74a3b
Merge branch 'main' into awsemf/defaultrollup
bryan-aguilar Jul 17, 2023
80447ef
Merge branch 'main' into awsemf/defaultrollup
bryan-aguilar Jul 17, 2023
60c5769
Merge branch 'main' into awsemf/defaultrollup
bryan-aguilar Jul 18, 2023
9f7f03e
Update .chloggen/awsemf_defaultrollup.yaml
bryan-aguilar Jul 19, 2023
256912c
Merge branch 'main' into awsemf/defaultrollup
bryan-aguilar Jul 19, 2023
5e19bc0
Merge branch 'main' into awsemf/defaultrollup
bryan-aguilar Jul 20, 2023
ba27c90
Merge branch 'main' into awsemf/defaultrollup
bryan-aguilar Jul 20, 2023
c00baaf
Merge branch 'main' into awsemf/defaultrollup
bryan-aguilar Jul 26, 2023
e339913
Merge branch 'main' into awsemf/defaultrollup
bryan-aguilar Jul 26, 2023
6522771
Merge branch 'main' into awsemf/defaultrollup
bryan-aguilar Jul 27, 2023
2834413
Merge branch 'main' into awsemf/defaultrollup
bryan-aguilar Jul 31, 2023
6586ac4
Merge branch 'awsemf/defaultrollup' of https://github.com/bryan-aguil…
bryan-aguilar Jul 31, 2023
040912c
Merge branch 'main' into awsemf/defaultrollup
bryan-aguilar Aug 1, 2023
8ff4b71
Merge branch 'main' into awsemf/defaultrollup
bryan-aguilar Aug 2, 2023
02adddf
Update exporter/awsemfexporter/factory.go
TylerHelmuth Aug 4, 2023
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
22 changes: 22 additions & 0 deletions .chloggen/awsemf_defaultrollup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Use this changelog template to create an entry for release notes.
# If your change doesn't affect end users, such as a test fix or a tooling change,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.

# 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: Add awsemf.nodimrollupdefault feature gate to aws emf exporter

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

# (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: |
Enabling the awsemf.nodimrollupdefault will cause the AWS EMF Exporter to use the NoDimensionRollup configuration
setting by default instead of ZeroAndSingleDimensionRollup.
8 changes: 4 additions & 4 deletions exporter/awsemfexporter/README.md

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions exporter/awsemfexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/confmap/confmaptest"
"go.opentelemetry.io/collector/featuregate"
"go.uber.org/zap"

"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsemfexporter/internal/metadata"
Expand Down Expand Up @@ -260,3 +261,12 @@ func TestValidateTags(t *testing.T) {
})
}
}

func TestNoDimensionRollupFeatureGate(t *testing.T) {
err := featuregate.GlobalRegistry().Set("awsemf.nodimrollupdefault", true)
require.NoError(t, err)
cfg := createDefaultConfig()

assert.Equal(t, cfg.(*Config).DimensionRollupOption, "NoDimensionRollup")
_ = featuregate.GlobalRegistry().Set("awsemf.nodimrollupdefault", false)
}
4 changes: 4 additions & 0 deletions exporter/awsemfexporter/emf_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ func newEmfExporter(config *Config, set exporter.CreateSettings) (*emfExporter,
pusherMap: map[cwlogs.PusherKey]cwlogs.Pusher{},
}

config.logger.Warn("the default value for DimensionRollupOption will be changing to NoDimensionRollup" +
"in a future release. See https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/23997 for more" +
"information")

return emfExporter, nil
}

Expand Down
8 changes: 7 additions & 1 deletion exporter/awsemfexporter/emf_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,12 @@ func TestNewExporterWithMetricDeclarations(t *testing.T) {

// Test output warning logs
expectedLogs := []observer.LoggedEntry{
{
Entry: zapcore.Entry{Level: zap.WarnLevel, Message: "the default value for DimensionRollupOption will be changing to NoDimensionRollup" +
"in a future release. See https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/23997 for more" +
"information"},
Context: []zapcore.Field{},
},
{
Entry: zapcore.Entry{Level: zap.WarnLevel, Message: "Dropped metric declaration."},
Context: []zapcore.Field{zap.Error(errors.New("invalid metric declaration: no metric name selectors defined"))},
Expand All @@ -598,7 +604,7 @@ func TestNewExporterWithMetricDeclarations(t *testing.T) {
Context: []zapcore.Field{zap.String("dimensions", "a,b,c,d,e,f,g,h,i,j,k")},
},
}
assert.Equal(t, 2, logs.Len())
assert.Equal(t, len(expectedLogs), logs.Len())
assert.Equal(t, expectedLogs, logs.AllUntimed())
}

Expand Down
14 changes: 13 additions & 1 deletion exporter/awsemfexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ import (
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/exporter/exporterhelper"
"go.opentelemetry.io/collector/featuregate"
"go.uber.org/zap"

"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsemfexporter/internal/metadata"
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/awsutil"
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/resourcetotelemetry"
)

var defaultNoRollupfg = featuregate.GlobalRegistry().MustRegister("awsemf.nodimrollupdefault", featuregate.StageAlpha,
featuregate.WithRegisterFromVersion("v0.82.0"),
TylerHelmuth marked this conversation as resolved.
Show resolved Hide resolved
featuregate.WithRegisterDescription("Changes the default AWS EMF Exporter Dimension rollup option to "+
"NoDimensionRollup"))

// NewFactory creates a factory for AWS EMF exporter.
func NewFactory() exporter.Factory {
return exporter.NewFactory(
Expand All @@ -26,12 +32,18 @@ func NewFactory() exporter.Factory {

// CreateDefaultConfig creates the default configuration for exporter.
func createDefaultConfig() component.Config {
var defaultDimensionRollupOption string
if defaultNoRollupfg.IsEnabled() {
defaultDimensionRollupOption = "NoDimensionRollup"
} else {
defaultDimensionRollupOption = "ZeroAndSingleDimensionRollup"
}
return &Config{
AWSSessionSettings: awsutil.CreateDefaultSessionConfig(),
LogGroupName: "",
LogStreamName: "",
Namespace: "",
DimensionRollupOption: "ZeroAndSingleDimensionRollup",
DimensionRollupOption: defaultDimensionRollupOption,
Version: "1",
RetainInitialValueOfDeltaMetric: false,
OutputDestination: "cloudwatch",
Expand Down
2 changes: 1 addition & 1 deletion exporter/awsemfexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ require (
go.opentelemetry.io/collector/confmap v0.82.0
go.opentelemetry.io/collector/consumer v0.82.0
go.opentelemetry.io/collector/exporter v0.82.0
go.opentelemetry.io/collector/featuregate v1.0.0-rcv0014
go.opentelemetry.io/collector/pdata v1.0.0-rcv0014
go.opentelemetry.io/collector/semconv v0.82.0
go.uber.org/zap v1.24.0
Expand Down Expand Up @@ -45,7 +46,6 @@ require (
go.opentelemetry.io/collector v0.82.0 // indirect
go.opentelemetry.io/collector/config/configtelemetry v0.82.0 // indirect
go.opentelemetry.io/collector/extension v0.82.0 // indirect
go.opentelemetry.io/collector/featuregate v1.0.0-rcv0014 // indirect
go.opentelemetry.io/collector/processor v0.82.0 // indirect
go.opentelemetry.io/collector/receiver v0.82.0 // indirect
go.opentelemetry.io/otel v1.16.0 // indirect
Expand Down