Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pkg/stanza] Add mute option for operators' error Handler #32145

Closed
ChrsMark opened this issue Apr 3, 2024 · 5 comments
Closed

[pkg/stanza] Add mute option for operators' error Handler #32145

ChrsMark opened this issue Apr 3, 2024 · 5 comments
Labels
enhancement New feature or request pkg/stanza

Comments

@ChrsMark
Copy link
Member

ChrsMark commented Apr 3, 2024

Component(s)

pkg/stanza

Describe the issue you're reporting

At the moment if an operator fails to parse an entry an error is logged by

func (t *TransformerOperator) HandleEntryError(ctx context.Context, entry *entry.Entry, err error) error {
.

For example given the following configuration:

operators:
      ...
      - type: move
        id: best_effort_move
        from: attributes.if_key
        to: attributes.val

where we want to apply the move on a best effort approach only if the if_key exists in the attributes, we will get the following error in the collector's logs:

2024-04-03T17:26:41.565+0300	error	helper/transformer.go:98	Failed to process entry	{"kind": "receiver", "name": "filelog", "data_type": "logs", "operator_id": "edo", "operator_type": "move", "error": "move: field does not exist: attributes.if_key", "action": "send"}
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/helper.(*TransformerOperator).HandleEntryError
	github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza@v0.97.0/operator/helper/transformer.go:98
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/helper.(*TransformerOperator).ProcessWith
	github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza@v0.97.0/operator/helper/transformer.go:90
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/transformer/move.(*Transformer).Process
	github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza@v0.97.0/operator/transformer/move/move.go:69
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/helper.(*WriterOperator).Write
	github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza@v0.97.0/operator/helper/writer.go:53
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/helper.(*TransformerOperator).ProcessWith
	github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza@v0.97.0/operator/helper/transformer.go:92
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/transformer/move.(*Transformer).Process
	github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza@v0.97.0/operator/transformer/move/move.go:69
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/helper.(*WriterOperator).Write
	github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza@v0.97.0/operator/helper/writer.go:53
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/transformer/recombine.(*Transformer).flushSource
	github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza@v0.97.0/operator/transformer/recombine/recombine.go:331
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/transformer/recombine.(*Transformer).Process
	github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza@v0.97.0/operator/transformer/recombine/recombine.go:253
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/helper.(*WriterOperator).Write
	github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza@v0.97.0/operator/helper/writer.go:53
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/helper.(*ParserOperator).ProcessWithCallback
	github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza@v0.97.0/operator/helper/parser.go:122
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/container.(*Parser).Process
	github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza@v0.97.0/operator/parser/container/container.go:166
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/helper.(*WriterOperator).Write
	github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza@v0.97.0/operator/helper/writer.go:53
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/input/file.(*Input).emit
	github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza@v0.97.0/operator/input/file/file.go:52
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/fileconsumer/internal/reader.(*Reader).ReadToEnd
	github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza@v0.97.0/fileconsumer/internal/reader/reader.go:89
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/fileconsumer.(*Manager).consume.func1
	github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza@v0.97.0/fileconsumer/file.go:181

However, there might be cases where users want to use an operator in a best effort way, and hence having an actual error log for each failure is sth that can bug the users and flood their logs as well.

There are 2 options that I can think here:

  1. log on debug level if OnError setting is SendOnError, otherwise if we DropOnError we can log on error level.
  2. add a new muteErrorLogs setting which will be decoupled by the OnError setting in order to have a specific way how to handle the verbosity of the operator's errors.
@ChrsMark ChrsMark added the needs triage New item requiring triage label Apr 3, 2024
Copy link
Contributor

github-actions bot commented Apr 3, 2024

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@djaglowski
Copy link
Member

There are 2 options that I can think here:

  1. log on debug level if OnError setting is SendOnError, otherwise if we DropOnError we can log on error level.
  2. add a new muteErrorLogs setting which will be decoupled by the OnError setting in order to have a specific way how to handle the verbosity of the operator's errors.

A muteErrorLogs setting seems to imply that it would affect log levels across the entire operator, which I don't think should be the intention here. Maybe with a different name this could work but even then it could be very confusing to have a second setting which trigger under exactly the same circumstances as on_error.

I typically don't like enumerating combinations but given the above, maybe it would be most intuitive to just add new options to on_error e.g. send_quiet and drop_quiet.

@ChrsMark
Copy link
Member Author

ChrsMark commented Apr 8, 2024

I typically don't like enumerating combinations but given the above, maybe it would be most intuitive to just add new options to on_error e.g. send_quiet and drop_quiet.

I think that would serve the purpose without making the configuration confusing.

@crobert-1
Copy link
Member

Removing needs triage based on code owner's response.

@crobert-1 crobert-1 removed the needs triage New item requiring triage label Apr 15, 2024
djaglowski added a commit that referenced this issue Apr 15, 2024
…ng (#32220)

**Description:** <Describe what has changed.>
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->

When stanza operators fail to process a message, no matter if they send
the message or drop it an error message is logged. This can be quite
"noisy" when users want to set up a best effort operator which on error
should only send/drop the message without logging an error.
With introducing the `send_quiet` and `drop_quiet` options we provide
the option to set the level of the logged error. `send_quiet` and
`drop_quiet` log the error on debug level.

**Link to tracking Issue:**
#32145

**Testing:** <Describe what testing was performed and which tests were
added.> Added
[unit-tests](https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/32220/files#diff-6a03331b322fcfd255ead096ac5c7c9dd9267a2d6697ea629548f37f4049896aR70)

**Documentation:** <Describe the documentation added.> [Enhanced the
operator's
docs](https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/32220/files#diff-8f730eb2d61d9ca8c5cf863e9e7f3ddfe51984c46c6259dd7258902d6cc10090L2)

---------

Signed-off-by: ChrsMark <chrismarkou92@gmail.com>
Co-authored-by: Daniel Jaglowski <jaglows3@gmail.com>
@djaglowski
Copy link
Member

Closed by #32220

ghost pushed a commit to opsramp/opentelemetry-collector-contrib that referenced this issue May 5, 2024
…ng (open-telemetry#32220)

**Description:** <Describe what has changed.>
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->

When stanza operators fail to process a message, no matter if they send
the message or drop it an error message is logged. This can be quite
"noisy" when users want to set up a best effort operator which on error
should only send/drop the message without logging an error.
With introducing the `send_quiet` and `drop_quiet` options we provide
the option to set the level of the logged error. `send_quiet` and
`drop_quiet` log the error on debug level.

**Link to tracking Issue:**
open-telemetry#32145

**Testing:** <Describe what testing was performed and which tests were
added.> Added
[unit-tests](https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/32220/files#diff-6a03331b322fcfd255ead096ac5c7c9dd9267a2d6697ea629548f37f4049896aR70)

**Documentation:** <Describe the documentation added.> [Enhanced the
operator's
docs](https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/32220/files#diff-8f730eb2d61d9ca8c5cf863e9e7f3ddfe51984c46c6259dd7258902d6cc10090L2)

---------

Signed-off-by: ChrsMark <chrismarkou92@gmail.com>
Co-authored-by: Daniel Jaglowski <jaglows3@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pkg/stanza
Projects
None yet
Development

No branches or pull requests

3 participants