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
34 stars 48 forks source link

Rework CI Visibility spans batching #379

Closed nikita-tkachenko-datadog closed 8 months ago

nikita-tkachenko-datadog commented 9 months ago

Requirements for Contributing to this repository

What does this PR do?

This PR adds logic that allows batching pipeline/job spans that the plugin submits: the logic that monitors jobs and pipelines calls the new TraceWriter to add a span to the current batch. The writer runs a background thread that gathers submitted spans into batches and submits them.

Each batch includes up to 100 spans (configurable via env vars), and the thread polls the queue at least every 10 seconds (configurable via env vars) or more frequently if the queue has more spans than fit into a single batch.

The motivation for adding this is:

There was a batching mechanism that existed before the changes (NonBlockingHttpClient), however it did not address the two points above: different jobs could not be batched together, and all of the spans had to be submitted in one call (which mandated waiting until the end of the pipeline to accumulate them).

Description of the Change

Alternate Designs

Possible Drawbacks

Verification Process

This does not change the plugin behaviour, so existing tests were used to verify there were no regressions. In addition, manual tests were executed in a dockerized Jenkins instance, covering the following:

Additional Notes

Release Notes

Review checklist (to be filled by reviewers)