Skip to content

Commit

Permalink
[pkg/stanza] Revert recombine operator 'overwrite_with' change (open-…
Browse files Browse the repository at this point in the history
…telemetry#32146)

Effectively reverts open-telemetry#30786, due to error pointed out by @yutingcaicyt
[here](open-telemetry#30786 (comment)).
  • Loading branch information
djaglowski authored Apr 3, 2024
1 parent d3d9b70 commit 6375418
Show file tree
Hide file tree
Showing 5 changed files with 9,488 additions and 19 deletions.
30 changes: 30 additions & 0 deletions .chloggen/pkg-stanza-revert-overwrite-with.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Use this changelog template to create an entry for release notes.

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

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Revert recombine operator's 'overwrite_with' default value.

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

# (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: |
Restores the previous the default value of `oldest`, meaning that the recombine operator will emit the
first entry from each batch (with the recombined field). This fixes the bug introduced by 30783 and restores
the default setting so as to effectively cancel out the bug for users who were not using this setting.
For users who were explicitly setting `overwrite_with`, this corrects the intended behavior.
# 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: []
10 changes: 5 additions & 5 deletions pkg/stanza/operator/transformer/recombine/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func NewConfigWithID(operatorID string) *Config {
MaxBatchSize: 1000,
MaxSources: 1000,
CombineWith: defaultCombineWith,
OverwriteWith: "newest",
OverwriteWith: "oldest",
ForceFlushTimeout: 5 * time.Second,
SourceIdentifier: entry.NewAttributeField("file.path"),
}
Expand Down Expand Up @@ -94,12 +94,12 @@ func (c *Config) Build(logger *zap.SugaredLogger) (operator.Operator, error) {
return nil, fmt.Errorf("missing required argument 'combine_field'")
}

var overwriteWithOldest bool
var overwriteWithNewest bool
switch c.OverwriteWith {
case "newest":
overwriteWithOldest = false
overwriteWithNewest = true
case "oldest", "":
overwriteWithOldest = true
overwriteWithNewest = false
default:
return nil, fmt.Errorf("invalid value '%s' for parameter 'overwrite_with'", c.OverwriteWith)
}
Expand All @@ -110,7 +110,7 @@ func (c *Config) Build(logger *zap.SugaredLogger) (operator.Operator, error) {
prog: prog,
maxBatchSize: c.MaxBatchSize,
maxSources: c.MaxSources,
overwriteWithOldest: overwriteWithOldest,
overwriteWithNewest: overwriteWithNewest,
batchMap: make(map[string]*sourceBatch),
batchPool: sync.Pool{
New: func() any {
Expand Down
4 changes: 2 additions & 2 deletions pkg/stanza/operator/transformer/recombine/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type Transformer struct {
prog *vm.Program
maxBatchSize int
maxSources int
overwriteWithOldest bool
overwriteWithNewest bool
combineField entry.Field
combineWith string
ticker *time.Ticker
Expand Down Expand Up @@ -154,7 +154,7 @@ func (t *Transformer) addToBatch(ctx context.Context, e *entry.Entry, source str
batch = t.addNewBatch(source, e)
} else {
batch.numEntries++
if t.overwriteWithOldest {
if t.overwriteWithNewest {
batch.baseEntry = e
}
}
Expand Down
24 changes: 12 additions & 12 deletions pkg/stanza/operator/transformer/recombine/transformer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ func TestTransformer(t *testing.T) {
return cfg
}(),
[]*entry.Entry{
entryWithBody(t1, "test1"),
entryWithBody(t2, "test2"),
entryWithBody(t2, "test1"),
entryWithBodyAttr(t1, "test1", map[string]string{"base": "false"}),
entryWithBodyAttr(t2, "test2", map[string]string{"base": "true"}),
entryWithBodyAttr(t2, "test1", map[string]string{"base": "false"}),
},
[]*entry.Entry{
entryWithBody(t1, "test1\ntest2"),
entryWithBodyAttr(t2, "test1\ntest2", map[string]string{"base": "true"}),
},
},
{
Expand All @@ -142,12 +142,12 @@ func TestTransformer(t *testing.T) {
return cfg
}(),
[]*entry.Entry{
entryWithBody(t1, "test1"),
entryWithBody(t2, "test2"),
entryWithBody(t2, "test1"),
entryWithBodyAttr(t1, "test1", map[string]string{"base": "true"}),
entryWithBodyAttr(t2, "test2", map[string]string{"base": "false"}),
entryWithBodyAttr(t2, "test1", map[string]string{"base": "true"}),
},
[]*entry.Entry{
entryWithBody(t2, "test1\ntest2"),
entryWithBodyAttr(t1, "test1\ntest2", map[string]string{"base": "true"}),
},
},
{
Expand All @@ -157,7 +157,7 @@ func TestTransformer(t *testing.T) {
cfg.CombineField = entry.NewBodyField()
cfg.IsFirstEntry = "$body == 'test1'"
cfg.OutputIDs = []string{"fake"}
cfg.OverwriteWith = "newest"
cfg.OverwriteWith = "oldest"
cfg.ForceFlushTimeout = 10 * time.Millisecond
return cfg
}(),
Expand All @@ -177,7 +177,7 @@ func TestTransformer(t *testing.T) {
cfg.CombineField = entry.NewBodyField()
cfg.IsFirstEntry = "body == 'start'"
cfg.OutputIDs = []string{"fake"}
cfg.OverwriteWith = "oldest"
cfg.OverwriteWith = "newest"
cfg.ForceFlushTimeout = 10 * time.Millisecond
return cfg
}(),
Expand Down Expand Up @@ -286,7 +286,7 @@ func TestTransformer(t *testing.T) {
cfg.CombineField = entry.NewBodyField("message")
cfg.CombineWith = ""
cfg.IsLastEntry = "body.logtag == 'F'"
cfg.OverwriteWith = "oldest"
cfg.OverwriteWith = "newest"
cfg.OutputIDs = []string{"fake"}
return cfg
}(),
Expand Down Expand Up @@ -380,7 +380,7 @@ func TestTransformer(t *testing.T) {
cfg.IsLastEntry = "body == 'end'"
cfg.OutputIDs = []string{"fake"}
cfg.MaxSources = 1
cfg.OverwriteWith = "oldest"
cfg.OverwriteWith = "newest"
cfg.ForceFlushTimeout = 10 * time.Millisecond
return cfg
}(),
Expand Down
Loading

0 comments on commit 6375418

Please sign in to comment.