You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[chore][pkg/stanza] Issue better error messages in case of misconfiguration (open-telemetry#42924)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
The container parser's `add_metadata_from_filepath` feature requires
`include_file_path` to be
enabled([docs](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/stanza/docs/operators/container.md#add-metadata-from-file-path)).
When `include_file_path` is disabled, users encounter an error message,
`type '<nil>' cannot be parsed as log path field`, which doesn't clearly
indicate the misconfiguration. This change provides users a better
explanation of the error.
Ideally, this misconfiguration should be detected during initialization
to fail fast. However, it may require significant changes since operator
configurations (file input, container parser, etc.) are separated and
highly abstracted. It seems like this approach is the simplest solution
for now.
<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
open-telemetry#42859
<!--Describe what testing was performed and which tests were added.-->
#### Testing
Added a unit test for the case.
---------
Co-authored-by: Christos Markou <[email protected]>
"operator '%s' has 'add_metadata_from_filepath' enabled, but the log record attribute '%s' is missing. Perhaps enable the 'include_file_path' option?",
279
+
p.OperatorID,
280
+
logPathField)
281
+
}
282
+
276
283
rawLogPath, ok:=logPath.(string)
277
284
if!ok {
278
285
returnfmt.Errorf("type '%T' cannot be parsed as log path field", logPath)
Body: `{"log":"INFO: log line here","stream":"stdout","time":"2029-03-30T08:31:20.545192187Z"}`,
201
+
},
202
+
"operator 'test_id' has 'add_metadata_from_filepath' enabled, but the log record attribute 'log.file.path' is missing. Perhaps enable the 'include_file_path' option?",
0 commit comments