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 aggregator #841

Merged
merged 25 commits into from
Jul 16, 2024
Merged

Conversation

andrewqian2001datadog
Copy link
Contributor

@andrewqian2001datadog andrewqian2001datadog commented Jul 3, 2024

What does this PR do?

This PR adds the aggregator functionality for client side aggregation, it is pushing to a feature branch. This has already been implemented for the GO client.

Issue

Description of the Change

Adds a class that periodically aggregates (this is not implemented yet as it will rely on functionality from the base.py class) metrics for a given flush_interval and then sends the aggregated metrics to intake. A metric will be aggregated if there was another matching context sent within the same flush interval.

Possible Drawbacks

A possible drawback is that the current code relies on object oriented programming (inheritance) for the add_metric and other functions, it requires that the MetricAggregator objects will have the same fields

Verification Process

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

Release Notes

No behavioral changes until the base.py class is changed

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 andrewqian2001datadog mentioned this pull request Jul 3, 2024
6 tasks
@andrewqian2001datadog andrewqian2001datadog changed the title add aggregator WIP add aggregator class Jul 3, 2024
@andrewqian2001datadog andrewqian2001datadog self-assigned this Jul 9, 2024
@andrewqian2001datadog andrewqian2001datadog marked this pull request as ready for review July 9, 2024 21:36
@andrewqian2001datadog andrewqian2001datadog requested review from a team as code owners July 9, 2024 21:36
@andrewqian2001datadog andrewqian2001datadog added the changelog/Added Added features results into a minor version bump label Jul 9, 2024
@andrewqian2001datadog andrewqian2001datadog changed the title add aggregator class add aggregator Jul 10, 2024
datadog/dogstatsd/metrics.py Outdated Show resolved Hide resolved
datadog/dogstatsd/metric_types.py Outdated Show resolved Hide resolved
datadog/dogstatsd/metrics.py Outdated Show resolved Hide resolved
datadog/dogstatsd/aggregator.py Outdated Show resolved Hide resolved
datadog/dogstatsd/metrics.py Outdated Show resolved Hide resolved
@andrewqian2001datadog

This comment was marked as resolved.

Copy link
Member

@gh123man gh123man left a comment

Choose a reason for hiding this comment

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

🚀

@andrewqian2001datadog andrewqian2001datadog merged commit b73d167 into add-client-side-aggregation Jul 16, 2024
9 checks passed
@andrewqian2001datadog andrewqian2001datadog deleted the add-aggregator branch July 16, 2024 18:50
andrewqian2001datadog added a commit that referenced this pull request Aug 12, 2024
* add aggregator  (#841)

* 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]>

* add flush_function parameter

* refactor base.py to use the aggregator

* revert test.yml change

* WIP

* disable buffering when aggregation is enabled

* add flush_aggregated_metrics function

* check whether or not _start_flush_thread is being called for buffering or aggregation before returning

* WIP

* finish disabling aggregation functions

* move line inside if statement

* fix lint

* fix lint 2

* fix lint

* fix renamed variable

* fix unit tests, rename variables

* check if thread is None

* fix tests

* fix tests

* rerun tests

* add back unicode

* revert lint to forking

* reverse lint changes

* add aggregation to increment

* TESTING

* revert name back to flush_interval

* test

* change setter name

* fix lint

* change order of disable aggregation and buffering

* test

* change order of disable aggregation and buffering

* remove setter design

* set default aggregation time interval

* fix lint

* remove function call

* fix lint

* do not allow buffering when aggregation is enabled

* testing for benchmarks

* check if removing logs fixes test

* add back logs

* remove logs

* rerun tests

* set default aggregation flush interval to 2 seconds

* remove print statement

* address comments

* use a single flush thread

* remove unecessary lint changes, fix refactored code

* add back import

* fix refactored code

* remove lint and comment

* check lint error

* fix variable naming, deleted test function

* add back imports for comment variables

* fix lint

* test add disable_aggregating to test_fork_hooks

* add parameter

* revert changes

* test

* check for tags = None

* remove test

* fix comment

* rename variable

* add flush function

---------

Co-authored-by: Brian Floersch <[email protected]>
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 resource/dogstatsd
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants