jenkinsci / datadog-plugin

A Jenkins plugin used to forward metrics, events, and service checks to an account at Datadog, automatically.
https://plugins.jenkins.io/datadog/
MIT License
30 stars 48 forks source link

Consider job inclusion/exclusion setting when tracking logs #432

Closed nikita-tkachenko-datadog closed 1 month ago

nikita-tkachenko-datadog commented 1 month ago

Requirements for Contributing to this repository

What does this PR do?

This PR updates logic that determines whether logs from a logger/taskListener should be sent to Datadog or not. After the update the logs will be tracked only if the job that they're coming from satisfies the plugin's include/exclude filters.

Description of the Change

org.datadog.jenkins.plugins.datadog.logs.DatadogConsoleLogFilter and org.datadog.jenkins.plugins.datadog.logs.DatadogTaskListenerDecorator are two main classes that decorate logging output streams with Datadog tracker. These two classes were updated to consult the plugin's settings as described above.

Alternate Designs

Possible Drawbacks

Verification Process

The logic was tested manually, and integration tests were implemented where appropriate.

Additional Notes

A common method is created in the utilities class that verifies whether a job should be tracked or not. It is meant to replace the existing method which verifiers the same using the job name (the reason is that the same logic extracting the name is repeated in multiple places).

Release Notes

Review checklist (to be filled by reviewers)