Skip to content

Commit

Permalink
[exporter/elasticsearch] deprecate 'dedot' config (#33780)
Browse files Browse the repository at this point in the history
**Description:**

Deprecate `exporter/elasticsearch`'s "dedot" configuration. In a future
release we will remove this configuration, and always dedot ECS mode,
never for raw/none modes.

**Link to tracking Issue:**


#33772

**Testing:**

N/A

**Documentation:**

Updated the README.
  • Loading branch information
axw authored Jun 28, 2024
1 parent 80d630b commit 90a0c90
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 2 deletions.
27 changes: 27 additions & 0 deletions .chloggen/elasticsearch-deprecate-dedot.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: deprecation

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Deprecate the "dedot" configuration.

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

# (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: dedot has been deprecated, and will always be enabled in ECS mode and disabled for other modes in future

# 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]
5 changes: 3 additions & 2 deletions exporter/elasticsearchexporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,9 @@ behaviours, which may be configured throug the following settings:
Try to find and remove duplicate fields/attributes from events before publishing
to Elasticsearch. Some structured logging libraries can produce duplicate fields
(for example zap). Elasticsearch will reject documents that have duplicate fields.
- `dedot` (default=true): When enabled attributes with `.` will be split into
proper json objects.
- `dedot` (default=true; DEPRECATED, in future dedotting will always be enabled
for ECS mode, and never for other modes): When enabled attributes with `.`
will be split into proper json objects.

#### ECS mapping mode

Expand Down
6 changes: 6 additions & 0 deletions exporter/elasticsearchexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ type MappingsSettings struct {
// as Elasticsearch will reject documents with duplicate JSON object keys.
Dedup bool `mapstructure:"dedup"`

// Deprecated: [v0.104.0] dedotting will always be applied for ECS mode
// in future, and never for other modes. Elasticsearch's "dot_expander"
// Ingest processor may be used as an alternative for non-ECS modes.
Dedot bool `mapstructure:"dedot"`
}

Expand Down Expand Up @@ -319,4 +322,7 @@ func logConfigDeprecationWarnings(cfg *Config, logger *zap.Logger) {
if !cfg.Mapping.Dedup {
logger.Warn("dedup has been deprecated, and will always be enabled in future")
}
if cfg.Mapping.Dedot && cfg.MappingMode() != MappingECS || !cfg.Mapping.Dedot && cfg.MappingMode() == MappingECS {
logger.Warn("dedot has been deprecated: in the future, dedotting will always be performed in ECS mode only")
}
}
40 changes: 40 additions & 0 deletions exporter/elasticsearchexporter/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ func TestFactory_DedupDeprecated(t *testing.T) {
cfg := withDefaultConfig(func(cfg *Config) {
cfg.Endpoint = "http://testing.invalid:9200"
cfg.Mapping.Dedup = false
cfg.Mapping.Dedot = false // avoid dedot warnings
})

loggerCore, logObserver := observer.New(zap.WarnLevel)
Expand All @@ -126,3 +127,42 @@ func TestFactory_DedupDeprecated(t *testing.T) {
assert.Equal(t, "dedup has been deprecated, and will always be enabled in future", records[1].Message)
assert.Equal(t, "dedup has been deprecated, and will always be enabled in future", records[2].Message)
}

func TestFactory_DedotDeprecated(t *testing.T) {
loggerCore, logObserver := observer.New(zap.WarnLevel)
set := exportertest.NewNopSettings()
set.Logger = zap.New(loggerCore)

cfgNoDedotECS := withDefaultConfig(func(cfg *Config) {
cfg.Endpoint = "http://testing.invalid:9200"
cfg.Mapping.Dedot = false
cfg.Mapping.Mode = "ecs"
})

cfgDedotRaw := withDefaultConfig(func(cfg *Config) {
cfg.Endpoint = "http://testing.invalid:9200"
cfg.Mapping.Dedot = true
cfg.Mapping.Mode = "raw"
})

for _, cfg := range []*Config{cfgNoDedotECS, cfgDedotRaw} {
factory := NewFactory()
logsExporter, err := factory.CreateLogsExporter(context.Background(), set, cfg)
require.NoError(t, err)
require.NoError(t, logsExporter.Shutdown(context.Background()))

tracesExporter, err := factory.CreateTracesExporter(context.Background(), set, cfg)
require.NoError(t, err)
require.NoError(t, tracesExporter.Shutdown(context.Background()))

metricsExporter, err := factory.CreateMetricsExporter(context.Background(), set, cfg)
require.NoError(t, err)
require.NoError(t, metricsExporter.Shutdown(context.Background()))
}

records := logObserver.AllUntimed()
assert.Len(t, records, 6)
for _, record := range records {
assert.Equal(t, "dedot has been deprecated: in the future, dedotting will always be performed in ECS mode only", record.Message)
}
}

0 comments on commit 90a0c90

Please sign in to comment.