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

Add client side aggregation #844

Merged
merged 68 commits into from
Aug 12, 2024
Merged

Conversation

andrewqian2001datadog
Copy link
Contributor

@andrewqian2001datadog andrewqian2001datadog commented Jul 17, 2024

Requirements for Contributing to this repository

  • Fill out the template below. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.
  • The pull request must only fix one issue, or add one feature, at the time.
  • The pull request must update the test suite to demonstrate the changed functionality.
  • After you create the pull request, all status checks must be pass before a maintainer reviews your contribution. For more details, please see CONTRIBUTING.

What does this PR do?

Project description

This PR adds simple client side aggregation (aggregating metrics before they are received by the agent) for the python client. This PR combines two previous PRs together (1, 2)

Client side aggregation has already been implemented in Go, Java, and the C# dogstatsd clients

Description of the Change

Periodically aggregates metrics (Count, Gauge, Set) for a given statsd_aggregation_flush_interval and then sends the aggregated metrics to intake. A metric will be aggregated if statsd_disable_aggregating is False and there was another matching context sent within the same flush interval.

Verification Process

Unit tests that verify the aggregator.py class matches the existing behavior in the client side aggregator for the go client.

Unit tests that verify the new metric objects (merics.py) match the existing behavior in the client side aggregator for Go.

Local testing:
Confluence doc
More Docs

Bench Mark tests (TODO as a stretch goal)

Additional Notes

We currently do not allow buffering and aggregation at the same time, if both enabled, aggregation will occur instead of buffering.

Release Notes

Review checklist (to be filled by reviewers)

  • Feature or bug fix MUST have appropriate tests (unit, integration, etc...)
  • PR title must be written as a CHANGELOG entry (see why)
  • Files changes must correspond to the primary purpose of the PR as described in the title (small unrelated changes should have their own PR)
  • PR must have one changelog/ label attached. If applicable it should have the backward-incompatible label attached.
  • PR should not have do-not-merge/ label attached.
  • If Applicable, issue must have kind/ and severity/ labels attached at least.

andrewqian2001datadog and others added 30 commits July 16, 2024 14:50
* add aggregator WIP

* add metric types enum

* add threading to metrics.py, add unsafe_flush

* fix aggregator

* add tests

* remove print statements

* remove lock for flush unsafe function

* fix removing wrong lock

* remove unecessary If

* Run tests on any branch

* Change MetricAggregator propreties so that it has all necessary fields to send to client

* change aggregator to use MetricAggregator type

* fix test

* fix lint

* remove enums

* fix lint x2

* fix lint x3

* use existing threading function

* remove import

* fix lint

* refactor _stop_flush_thread

* rename variable

* remove client from aggregator

* move changes to base.py to next PR

---------

Co-authored-by: Brian Floersch <[email protected]>
rayz
rayz previously approved these changes Aug 9, 2024
Copy link

@rayz rayz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

skarimo
skarimo previously approved these changes Aug 9, 2024
datadog/__init__.py Outdated Show resolved Hide resolved
datadog/__init__.py Show resolved Hide resolved
skarimo
skarimo previously approved these changes Aug 9, 2024
rayz
rayz previously approved these changes Aug 12, 2024
@andrewqian2001datadog
Copy link
Contributor Author

/merge

@dd-devflow
Copy link

dd-devflow bot commented Aug 12, 2024

🚂 MergeQueue: pull request added to the queue

The median merge time in master is 58m.

Use /merge -c to cancel this operation!

@dd-devflow
Copy link

dd-devflow bot commented Aug 12, 2024

MergeQueue: The build pipeline has timeout

The merge request has been interrupted because the build took longer than expected. The current limit for the base branch 'master' is 120 minutes.

If you need support, contact us on Slack #devflow with those details!

@andrewqian2001datadog andrewqian2001datadog merged commit 74ffb61 into master Aug 12, 2024
11 checks passed
@andrewqian2001datadog andrewqian2001datadog deleted the add-client-side-aggregation branch August 12, 2024 17:32
andrewqian2001datadog added a commit that referenced this pull request Aug 12, 2024
@andrewqian2001datadog andrewqian2001datadog mentioned this pull request Aug 12, 2024
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/Added Added features results into a minor version bump mergequeue-status: rejected resource/dogstatsd
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants