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 metric object type #837

Merged
merged 9 commits into from
Jul 8, 2024
Merged

add metric object type #837

merged 9 commits into from
Jul 8, 2024

Conversation

andrewqian2001datadog
Copy link
Contributor

@andrewqian2001datadog andrewqian2001datadog commented Jun 26, 2024

What does this PR do?

This PR is for adding metric objects that will make aggregation easier by allowing us to have one Metric object instantiation for each unique metric context that we can add samples to which will make aggregation easier. Existing behavior already exists in the client side aggregation for GO

Description of the Change

Create metric object type (MetricAgggregator) that other metric objects (CountMetric, GaugeMetric, etc.) implement that will enforce the objects to implement functions aggregate and potentially flush_unsafe. This should also allow us to group the different metric types together in one list to be sent when we flush the metrics.

Possible Drawbacks

Some future metrics may not have the necessary fields to be of type MetricAggregator

image

The existing code for flushing metrics does NOT use object oriented programming, as a result they have duplicate code for each metric type.
image

Maybe i'm missing the potential drawbacks to using object oriented programming (specifically inheritance)?

Update:
image

Verification Process

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

Additional Notes

The python dogstatsd API will need to be refactored in the future to use these metric objects.

Release Notes

N/A, no new behavior until the aggregator class is implemented

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 self-assigned this Jun 27, 2024
@andrewqian2001datadog andrewqian2001datadog marked this pull request as ready for review June 27, 2024 19:18
@andrewqian2001datadog andrewqian2001datadog added the changelog/Added Added features results into a minor version bump label Jun 27, 2024
@andrewqian2001datadog andrewqian2001datadog changed the title add metric objects add metric object type Jun 27, 2024
datadog/dogstatsd/metrics.py Outdated Show resolved Hide resolved
datadog/dogstatsd/metrics.py Outdated Show resolved Hide resolved
super(SetMetric, self).__init__(name, tags, rate)
self.data = set()
self.data.add(value)
self.lock = Lock()
Copy link
Member

Choose a reason for hiding this comment

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

Similarly - maybe we should wait to add synchronization primitives until we actually have multithreaded code running. We can keep this PR focused to just introducing the metric classes and their associated properties.

Copy link
Contributor Author

@andrewqian2001datadog andrewqian2001datadog Jun 30, 2024

Choose a reason for hiding this comment

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

the serialization function needs values like namespace and container_id which is set in the base.py class. I think it would be more convenient to leave it as a function in base.py or move it to aggregator.py? Not sure.

This is what aggregator.py looks like so far

Maybe we can move the serialization function there since it should have access to the DogStatsd client (it does in the existing go code) and its properties? It seems more intuitive that aggregator.py would handle serialization of a metric.

gh123man
gh123man previously approved these changes Jul 1, 2024
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.

LGTM!

@andrewqian2001datadog
Copy link
Contributor Author

/merge

@dd-devflow
Copy link

dd-devflow bot commented Jul 1, 2024

🚂 MergeQueue: pull request added to the queue

The median merge time in master is 0s.

Use /merge -c to cancel this operation!

@andrewqian2001datadog
Copy link
Contributor Author

/remove

@dd-devflow
Copy link

dd-devflow bot commented Jul 1, 2024

🚂 Devflow: /remove

@dd-devflow
Copy link

dd-devflow bot commented Jul 3, 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
Copy link
Contributor Author

/merge

@dd-devflow
Copy link

dd-devflow bot commented Jul 5, 2024

🚂 MergeQueue: pull request added to the queue

The median merge time in master is 0s.

Use /merge -c to cancel this operation!

@dd-devflow
Copy link

dd-devflow bot commented Jul 5, 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
Copy link
Contributor Author

/merge

@dd-devflow
Copy link

dd-devflow bot commented Jul 8, 2024

🚂 MergeQueue: waiting for PR to be ready

This merge request is not mergeable yet, because of pending checks/missing approvals. It will be added to the queue as soon as checks pass and/or get approvals.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.

Use /merge -c to cancel this operation!

@dd-devflow
Copy link

dd-devflow bot commented Jul 8, 2024

🚂 MergeQueue: pull request added to the queue

The median merge time in master is 0s.

Use /merge -c to cancel this operation!

@dd-devflow
Copy link

dd-devflow bot commented Jul 8, 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 8ba18e8 into master Jul 8, 2024
53 of 58 checks passed
@andrewqian2001datadog andrewqian2001datadog deleted the add-metric-objects branch July 8, 2024 19:21
@dbenamydd dbenamydd restored the add-metric-objects branch July 10, 2024 04:26
@dbenamydd dbenamydd deleted the add-metric-objects branch July 10, 2024 04:34
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants