Skip to content

Allow inline configuration vs file paths - #46

Open
mjcheetham wants to merge 4 commits into
mainfrom
inline-config
Open

Allow inline configuration vs file paths#46
mjcheetham wants to merge 4 commits into
mainfrom
inline-config

Conversation

@mjcheetham

@mjcheetham mjcheetham commented Feb 12, 2026

Copy link
Copy Markdown
Contributor

I’ll base the draft on the rewritten four-commit series and the final diff against main, including the compatibility behavior and review-driven fixes.

Summary

Allow the pii, filter, and summary settings to be defined inline in the main OpenTelemetry Collector configuration. This makes it possible to configure trace2receiver using a single YAML file instead of requiring separate settings files.

Each setting now accepts:

  • An inline YAML object.
  • A Collector-expanded ${file:PATH} value.
  • A plain file path string for compatibility with existing configurations.

The receiver decodes the string-or-object values into exported raw carrier fields, then resolves them into typed PiiSettings, FilterSettings, and SummarySettings during validation.

Validation

Move validation onto the settings types so it is shared by inline and file-backed configuration. In particular, important_events rules receive the same required-field and duplicate-field checks regardless of how the filter settings were supplied.

Compatibility

Existing Collector YAML files using plain PII, filter, or summary path strings continue to work.

The Go configuration API has changed. Consumers that construct Config values directly must use the new typed Pii, Filter, and Summary fields, or the corresponding RawPii, RawFilter, and RawSummary carrier fields when exercising configuration decoding.

Documentation

Update the configuration reference and example collectors to show:

  • Inline settings.
  • External files using ${file:PATH}.
  • Backward-compatible plain path strings.
  • The different YAML shapes required for inline settings and standalone settings files.

Testing

Add coverage that loads complete receiver stanzas through the Collector’s confmap decoder and verifies both inline objects and plain file-path strings. Existing parser and validation tests continue to cover malformed files, missing files, summary rules, filter rules, and important_events.

go test ./...

@mjcheetham mjcheetham changed the title [Breaking Change] Use inline configuration Allow inline configuration vs file paths Feb 12, 2026
@mjcheetham
mjcheetham marked this pull request as ready for review February 12, 2026 17:40

@derrickstolee derrickstolee left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this idea! I've taken a look and things seem reasonable.

It's worth noting that this is backwards-compatible with existing config files which is important. However, it is not backwards-compatible for compiling with consumers. Consumers may need to make a code update now that the data structures have changed.

Comment thread config_test.go
Comment on lines -325 to -334
summaryContent := `
message_patterns:
- prefix: "error:"
field_name: "error_count"

region_timers:
- category: "index"
label: "do_read_index"
time_field: "index_read_time"
`

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these kinds of yaml-string parsing tests are important, and my AI agent is warning that some of the parsing code might be fragile without explicit pairing of config member and yaml text. I know that we don't want this "summary path" option to be the main test, but this summary content should be tested for parsing in the inline way.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. I'll update Test_Config_Validate_WithAllOptionalSettings to retain raw YAML text for pii, filter, and summary. We can parse that YAML, explicitly pairing each member with its corresponding config field, and verify the resulting typed values after validation.

This will also mean exercising the inline object parsing, including the message_patterns, field_name, and region_timers mappings rather than making the legacy file path form the main test.

@mjcheetham
mjcheetham force-pushed the inline-config branch 2 times, most recently from d12be64 to 3c4a160 Compare September 11, 2026 11:34
@mjcheetham
mjcheetham requested a balanced review from Copilot September 11, 2026 13:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Collector decoding cannot populate the private raw fields, and inline important-event validation is incomplete.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Refactors receiver configuration to support inline PII, filter, and summary settings while retaining file-based configuration.

Changes:

  • Adds inline configuration decoding and validation.
  • Updates runtime consumers and tests to use typed settings.
  • Revises documentation and examples for both configuration styles.
File summaries
File Description
config.go Introduces inline/file configuration resolution.
config_test.go Updates configuration validation tests.
factory.go Removes obsolete path defaults.
filter_settings.go Extracts filter validation.
important_events_test.go Uses exported filter and summary fields.
platform_unix.go Reads typed PII settings on Unix.
platform_windows.go Reads typed PII settings on Windows.
rcvr_base.go Logs enabled typed PII settings.
summary.go Uses exported summary settings.
summary_settings.go Extracts summary validation.
summary_test.go Uses exported configuration fields.
trace2dataset.go Uses typed filter and summary settings.
Docs/config-filter-settings.md Documents inline filter configuration.
Docs/config-pii-settings.md Documents inline PII configuration.
Docs/configure-custom-collector.md Documents receiver configuration options.
Docs/Examples/DebugDump/config.yml Demonstrates inline settings.
Docs/Examples/ExportToAzureMonitor/config.yml Demonstrates inline settings.
Review details
  • Files reviewed: 17/17 changed files
  • Comments generated: 6
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread config.go Outdated
Comment thread config_test.go Outdated
Comment thread filter_settings.go
Comment thread Docs/config-filter-settings.md
Comment thread Docs/config-pii-settings.md
Comment thread Docs/configure-custom-collector.md
Separate settings files prevent using a single Collector configuration.
Replace the pathname fields with typed PII, filter, and summary
settings that the Collector can populate directly.

Update runtime consumers and tests in the same commit so the tree
remains buildable. Keep validation on the settings types so inline
configuration receives the same checks as parsed YAML files.

Assisted-by: Claude Opus 4.6
Assisted-by: GPT-5.6 Sol
Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
Describe PII, filter, and summary settings as inline receiver
configuration and update the example collectors to use that form.

Document ${file:PATH} as the external-file option and distinguish the
receiver-level wrapper from the contents expected in standalone PII
and filter files.

Assisted-by: Claude Opus 4.6
Assisted-by: GPT-5.6 Sol
Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
Existing deployments may provide bare file paths for PII, filter,
and summary settings. Preserve that syntax while continuing to accept
inline objects and Collector-expanded ${file:PATH} values.

Use exported raw carrier fields so the Collector decoder can populate
the string-or-object values, then resolve them into typed runtime
settings during validation. Exercise complete receiver stanzas through
confmap for both inline objects and legacy paths.

Assisted-by: Claude Opus 4.6
Assisted-by: GPT-5.6 Sol
Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
Explain that PII, filter, and summary settings continue to accept
bare file paths for existing deployments. Show the complete receiver
example and clarify that standalone files omit their receiver-level
wrapper keys.

Assisted-by: Claude Opus 4.6
Assisted-by: GPT-5.6 Sol
Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
@mjcheetham

Copy link
Copy Markdown
Contributor Author

@derrickstolee please could I have another review of this PR please? I've restructured the commits and made a few edits:

  • Kept the inline configuration change separate from the restoration of legacy plain-path support.
  • Added Collector-level tests that decode complete receiver configurations for both inline objects and plain file paths.
  • Fixed the raw configuration fields so the Collector can populate them during decoding.
  • Applied important_events validation consistently to inline and file-backed filter settings.
  • Clarified the different YAML shapes used for inline settings and standalone files.
  • Updated the plain-path examples to cover PII, filter, and summary settings.

Hopefully this addresses concerns Copilot and your AI Agent had.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants