diff --git a/.github/workflows/changelog.yaml b/.github/workflows/changelog.yaml index 6dd28dcc4..c3454b79c 100644 --- a/.github/workflows/changelog.yaml +++ b/.github/workflows/changelog.yaml @@ -1,4 +1,8 @@ name: "Ensure labels" + +permissions: + pull-requests: read + on: # yamllint disable-line rule:truthy pull_request: types: diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 330c87a2f..387ae5dd1 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -1,5 +1,9 @@ name: "CodeQL" +permissions: + contents: read + checks: write + on: push: branches: [ master ] diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 0bd3565ac..efe88ab83 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -1,4 +1,9 @@ name: "Pull Request Labeler" + +permissions: + contents: read + pull-requests: write + on: - pull_request diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 8008ff16f..1898f83c6 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,5 +1,9 @@ name: Build +permissions: + contents: write + pull-requests: write + on: pull_request: release: diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index c5291bfc5..51f9ad156 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -1,6 +1,12 @@ # Configuration for https://github.com/actions/stale name: "Stale issues and pull requests" + +permissions: + contents: write + issues: write + pull-requests: write + on: schedule: - cron: "0 5 * * *" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a81b1ed51..0880f7f7f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,5 +1,8 @@ name: test +permissions: + contents: read + on: push: branches: diff --git a/.github/workflows/test_integration.yml b/.github/workflows/test_integration.yml index cd8d494ad..152c0b500 100644 --- a/.github/workflows/test_integration.yml +++ b/.github/workflows/test_integration.yml @@ -1,5 +1,8 @@ name: Run Integration Tests +permissions: + contents: read + on: # yamllint disable-line rule:truthy pull_request: types: diff --git a/CHANGELOG.md b/CHANGELOG.md index e46391318..c9e32dce2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.50.1 / 2024-09-18 + +* [Added] Add the ability for buffering and aggregation to work at the same time. See [#851](https://github.com/DataDog/datadogpy/pull/851). + ## v0.50.0 / 2024-08-20 * [Added] Add client side aggregation. See [#844](https://github.com/DataDog/datadogpy/pull/844). diff --git a/RELEASING.md b/RELEASING.md index 2d8c3e9fb..f3e6e16b1 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -21,7 +21,7 @@ This project does not have a strict release schedule. However, we would make a r Our team will trigger the release pipeline. ### Prerequisite -- Install [datadog_checks_dev](https://datadog-checks-base.readthedocs.io/en/latest/datadog_checks_dev.cli.html#installation) using Python 3. +- Install [datadog_checks_dev](https://datadoghq.dev/integrations-core/setup/#ddev) using Python 3. - Setup PyPI, see the internal documentation for more details ### Update Changelog and version diff --git a/datadog/dogstatsd/aggregator.py b/datadog/dogstatsd/aggregator.py index 4a805b75e..e2896af3d 100644 --- a/datadog/dogstatsd/aggregator.py +++ b/datadog/dogstatsd/aggregator.py @@ -4,6 +4,11 @@ GaugeMetric, SetMetric, ) +from datadog.dogstatsd.buffered_metrics import ( + HistogramMetric, + DistributionMetric, + TimingMetric +) from datadog.dogstatsd.metric_types import MetricType @@ -14,10 +19,18 @@ def __init__(self): MetricType.GAUGE: {}, MetricType.SET: {}, } + self.buffered_metrics_map = { + MetricType.HISTOGRAM: {}, + MetricType.DISTRIBUTION: {}, + MetricType.TIMING: {} + } self._locks = { MetricType.COUNT: threading.RLock(), MetricType.GAUGE: threading.RLock(), MetricType.SET: threading.RLock(), + MetricType.HISTOGRAM: threading.RLock(), + MetricType.DISTRIBUTION: threading.RLock(), + MetricType.TIMING: threading.RLock() } def flush_aggregated_metrics(self): @@ -30,6 +43,16 @@ def flush_aggregated_metrics(self): metrics.extend(metric.get_data() if isinstance(metric, SetMetric) else [metric]) return metrics + def flush_aggregated_buffered_metrics(self): + metrics = [] + for metric_type in self.buffered_metrics_map.keys(): + with self._locks[metric_type]: + current_metrics = self.buffered_metrics_map[metric_type] + self.buffered_metrics_map[metric_type] = {} + for metric in current_metrics.values(): + metrics.append(metric) + return metrics + def get_context(self, name, tags): tags_str = ",".join(tags) if tags is not None else "" return "{}:{}".format(name, tags_str) @@ -60,3 +83,4 @@ def add_metric( self.metrics_map[metric_type][context] = metric_class( name, value, tags, rate, timestamp ) + diff --git a/datadog/version.py b/datadog/version.py index 34f41b46c..0b5aa08f1 100644 --- a/datadog/version.py +++ b/datadog/version.py @@ -1 +1 @@ -__version__ = "0.50.1.dev" +__version__ = "0.50.2.dev"