elastic / apm-agent-php

Apache License 2.0
253 stars 69 forks source link

More control over curl with instrumentation - e.g don't log some timeouts to APM Error log #1208

Open igor748 opened 2 months ago

igor748 commented 2 months ago

Don't want to log some expected errors from curl We have some expected errors that we don't want to log to APM e.g timeouts to some urls. These errors are automatically logged by apm agent during curl_exec and we can't prevent it in later checking of curl response codes.

To have control of which stuff is logged Some kind of try/catch logic where we can choose what will be logged and what will be handled with our code without logging to APM Error log.

groensch24 commented 2 months ago

To give a good use-case why that is important to us.

We allow our customers to integrate external systems into ours. They see a log on the messages that go out and in and if there is an error they will see that and can react on it. So those errors are expected and part of our business. They are not something we have to be alerted on.

Now, the module for curls sends all timeouts or other errors there. That means everytime we do deployments or want to see how well our application it is, it will be flooded with errors that are not really a problem.

intuibase commented 2 months ago

Hey @igor748 @groensch24

Have you tried to use Elastic agent drop events feature to solve this problem? https://www.elastic.co/guide/en/fleet/current/drop_event-processor.html

This allows exceptions to be filtered out according to a number of rules and conditions (like equals, contains, etc). It can be by exception, name, message, etc Here is a sample part of apm-server.yml file:

processors:
  - drop_event:
      when:
        - equals:
            error.exception.type: "IgnoredException"
  - drop_event:
      when:
        contains:
          error.exception.message: "curl error..."