Skip to content

Commit

Permalink
can -> MUST
Browse files Browse the repository at this point in the history
  • Loading branch information
djaglowski committed Nov 17, 2022
1 parent cd1f5a6 commit 3a5f156
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
16 changes: 16 additions & 0 deletions .chloggen/processor-duplication-per-pipeline.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: bug_fix

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Disallow duplicate references to processors within a single pipeline

# One or more tracking issues or pull requests related to the change
issues: [6540]

# (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:
2 changes: 1 addition & 1 deletion docs/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ When the Collector loads this config the result will look like this:

Note that each `batch` processor is an independent instance, although both are configured the same way, i.e. each have a `send_batch_size` of 10000.

The same name of the processor can NOT be referenced multiple times in the `processors` key of a single pipeline.
The same name of the processor MUST NOT be referenced multiple times in the `processors` key of a single pipeline.

## <a name="opentelemetry-agent"></a>Running as an Agent

Expand Down
7 changes: 7 additions & 0 deletions service/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,18 @@ func (cfg *Config) validateService() error {
}

// Validate pipeline processor name references.
procSet := make(map[component.ID]bool, len(cfg.Processors))
for _, ref := range pipeline.Processors {
// Check that the name referenced in the pipeline's processors exists in the top-level processors.
if cfg.Processors[ref] == nil {
return fmt.Errorf("pipeline %q references processor %q which does not exist", pipelineID, ref)
}
// Ensure no processors are duplicated within the pipeline
if _, exists := procSet[ref]; exists {

return fmt.Errorf("pipeline %q references processor %q multiple times", pipelineID, ref)
}
procSet[ref] = true
}

// Validate pipeline has at least one exporter.
Expand Down
10 changes: 10 additions & 0 deletions service/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,16 @@ func TestConfigValidate(t *testing.T) {
},
expected: errors.New(`pipeline "traces" references processor "nop/2" which does not exist`),
},
{
name: "duplicate-processor-reference",
cfgFn: func() *Config {
cfg := generateConfig()
pipe := cfg.Service.Pipelines[component.NewID("traces")]
pipe.Processors = append(pipe.Processors, pipe.Processors...)
return cfg
},
expected: errors.New(`pipeline "traces" references processor "nop" multiple times`),
},
{
name: "invalid-exporter-reference",
cfgFn: func() *Config {
Expand Down

0 comments on commit 3a5f156

Please sign in to comment.