From 8bb75df5a907bf980f59d02470b23fd65241ffd6 Mon Sep 17 00:00:00 2001 From: Hippolyte HENRY Date: Thu, 15 Apr 2021 19:59:47 +0200 Subject: [PATCH] Release 0.41.0 (#650) --- .github/workflows/changelog.yaml | 22 ++++++++++++++ .github/workflows/release.yaml | 36 +++++++++++++++++++++++ CHANGELOG.md | 10 +++++-- RELEASING.md | 20 ++++++------- datadog/dogstatsd/base.py | 45 +++++++++++++++++------------ datadog/version.py | 2 +- tests/unit/dogstatsd/test_statsd.py | 16 +++++----- 7 files changed, 110 insertions(+), 41 deletions(-) create mode 100644 .github/workflows/changelog.yaml create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/changelog.yaml b/.github/workflows/changelog.yaml new file mode 100644 index 000000000..6dd28dcc4 --- /dev/null +++ b/.github/workflows/changelog.yaml @@ -0,0 +1,22 @@ +name: "Ensure labels" +on: # yamllint disable-line rule:truthy + pull_request: + types: + - labeled + - unlabeled + - opened + - synchronize + - reopened + - ready_for_review + +jobs: + changelog: + runs-on: ubuntu-latest + steps: + - name: Check changelog labels + if: github.event.pull_request.draft == false && false == contains(join(github.event.pull_request.labels.*.name, ','), 'changelog/') + run: |- + echo "::error Add 'changelog/*' label"; + exit 1; + - name: OK + run: echo "Thank you!" diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 000000000..e6b4527d2 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,36 @@ +name: Build + +on: + pull_request: + release: + types: + - published + +jobs: + build_wheels: + name: Build wheels on Ubuntu 20.04 + runs-on: ubuntu-20.04 + if: github.event_name == 'release' && github.event.action == 'published' + steps: + - uses: actions/checkout@v2 + # Include all history and tags, needed for building the right version + with: + fetch-depth: 0 + + - uses: actions/setup-python@v2 + name: Install Python + with: + python-version: '3.9' + + - name: Install datadog_checks_dev + run: | + python -m pip install datadog_checks_dev[cli] + + - name: Set ddev pypi credentials + run: | + ddev config set pypi.user __token__ + ddev config set pypi.pass ${{ secrets.PYPI_TOKEN }} + + - name: Publish the wheel to PyPI + run: | + ddev release upload . --sdist diff --git a/CHANGELOG.md b/CHANGELOG.md index 3643135ce..1218690e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ -CHANGELOG -========= +# Changelog + +## 0.41.0 / 2021-04-15 + +* [Fixed] Fix decorator dependency for Python 2.7. See [#646](https://github.com/DataDog/datadogpy/pull/646). Thanks [artem888881](https://github.com/artem888881). +* [Fixed] [dogstatsd] Fix buffer operation thread-safety. See [#642](https://github.com/DataDog/datadogpy/pull/642). +* [Fixed] [dogstatsd] Improve performance of telemetry serialization. See [#641](https://github.com/DataDog/datadogpy/pull/641). + ## 0.40.1 / 2021-03-01 * [Fixed] Fix blocking connections in dogstatsd. See [#634](https://github.com/DataDog/datadogpy/pull/634). diff --git a/RELEASING.md b/RELEASING.md index 6ca3aaaea..2d8c3e9fb 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -24,17 +24,15 @@ Our team will trigger the release pipeline. - Install [datadog_checks_dev](https://datadog-checks-base.readthedocs.io/en/latest/datadog_checks_dev.cli.html#installation) using Python 3. - Setup PyPI, see the internal documentation for more details -### Update Changelog -#### Commands -- See changes ready for release by running `ddev release show changes .` at the root of this project. Add any missing labels to PRs if needed. -- Run `ddev release changelog . ` to update the `CHANGELOG.md` file at the root of this repository -- Commit the changes to the repository in a release branch and open a PR. Do not merge yet. +### Update Changelog and version -### Release +1. See changes ready for release by running `ddev release show changes .` at the root of this project. Add any missing labels to PRs if needed. +1. Run `ddev release changelog . ` to update the `CHANGELOG.md` file at the root of this repository +1. Commit the changes to the repository in a release branch and open a PR. Do not merge yet. 1. Bump the version in [`datadog/version.py`](datadog/version.py) and push it to your changelog PR. [Example](https://github.com/DataDog/datadogpy/pull/495/files#diff-2eeaed663bd0d25b7e608891384b7298) 1. Merge the PR to master. -1. Create the release on GitHub. [Example](https://github.com/DataDog/datadogpy/releases/tag/v0.33.0) -1. Checkout the tag created at the previous step. -1. Run `ddev release build .` and `ddev release upload --sdist . `. - - Make sure that both an `sdist` and a [universal wheel](https://packaging.python.org/guides/distributing-packages-using-setuptools/#universal-wheels) have been uploaded to [PyPI](https://pypi.python.org/pypi/datadog/). -1. Bump the version again in `datadog/version.py` to a dev version (e.g. `0.34.0` -> `0.34.1.dev`), open a PR and merge it to master. + +### Release +1. Create the release on GitHub. [Example](https://github.com/DataDog/datadogpy/releases/tag/0.40.0) +1. A github action will kick off that builds and publishes this tag to PyPI. Confirm the [release is available](https://pypi.org/project/datadog/#history) +1. Bump the version again in `datadog/version.py` to a dev version (e.g. `0.34.0` -> `0.34.1.dev`), open a PR and merge it to master. \ No newline at end of file diff --git a/datadog/dogstatsd/base.py b/datadog/dogstatsd/base.py index ffe3b678d..2edec876d 100644 --- a/datadog/dogstatsd/base.py +++ b/datadog/dogstatsd/base.py @@ -54,15 +54,17 @@ # Telemetry pre-computed formatting string. Pre-computation # increases throughput of composing the result by 2-15% from basic # '%'-based formatting with a `join`. -TELEMETRY_FORMATTING_STR = "\n".join([ - "datadog.dogstatsd.client.metrics:%s|c|#%s", - "datadog.dogstatsd.client.events:%s|c|#%s", - "datadog.dogstatsd.client.service_checks:%s|c|#%s", - "datadog.dogstatsd.client.bytes_sent:%s|c|#%s", - "datadog.dogstatsd.client.bytes_dropped:%s|c|#%s", - "datadog.dogstatsd.client.packets_sent:%s|c|#%s", - "datadog.dogstatsd.client.packets_dropped:%s|c|#%s", -]) +TELEMETRY_FORMATTING_STR = "\n".join( + [ + "datadog.dogstatsd.client.metrics:%s|c|#%s", + "datadog.dogstatsd.client.events:%s|c|#%s", + "datadog.dogstatsd.client.service_checks:%s|c|#%s", + "datadog.dogstatsd.client.bytes_sent:%s|c|#%s", + "datadog.dogstatsd.client.bytes_dropped:%s|c|#%s", + "datadog.dogstatsd.client.packets_sent:%s|c|#%s", + "datadog.dogstatsd.client.packets_dropped:%s|c|#%s", + ] +) class DogStatsd(object): @@ -374,8 +376,8 @@ def close_buffer(self): invocation. """ - if not hasattr(self, 'buffer'): - raise BufferError('Cannot close buffer that was never opened') + if not hasattr(self, "buffer"): + raise BufferError("Cannot close buffer that was never opened") try: self._send = self._send_to_server @@ -591,13 +593,20 @@ def _flush_telemetry(self): telemetry_tags = ",".join(self._add_constant_tags(self._client_tags)) return TELEMETRY_FORMATTING_STR % ( - self.metrics_count, telemetry_tags, - self.events_count, telemetry_tags, - self.service_checks_count, telemetry_tags, - self.bytes_sent, telemetry_tags, - self.bytes_dropped, telemetry_tags, - self.packets_sent, telemetry_tags, - self.packets_dropped, telemetry_tags + self.metrics_count, + telemetry_tags, + self.events_count, + telemetry_tags, + self.service_checks_count, + telemetry_tags, + self.bytes_sent, + telemetry_tags, + self.bytes_dropped, + telemetry_tags, + self.packets_sent, + telemetry_tags, + self.packets_dropped, + telemetry_tags, ) def _is_telemetry_flush_time(self): diff --git a/datadog/version.py b/datadog/version.py index bcd8f1682..22ffde200 100644 --- a/datadog/version.py +++ b/datadog/version.py @@ -1 +1 @@ -__version__ = "0.41.0.dev" +__version__ = "0.41.0" diff --git a/tests/unit/dogstatsd/test_statsd.py b/tests/unit/dogstatsd/test_statsd.py index 914185fea..519929386 100644 --- a/tests/unit/dogstatsd/test_statsd.py +++ b/tests/unit/dogstatsd/test_statsd.py @@ -738,15 +738,13 @@ def batch_metrics(index, dsd): # This is a bit of a tricky thing to test for - initially only our data packet is # sent but then telemetry is flushed/reset and the subsequent metric xmit includes - # the telemetry data for the previous packet. The reason for 726 -> 727 increase is - # because packet #2 sends a three digit byte count ("726") that then increases the - # next metric size by 1 byte. - expected_xfer_metrics = [ - (33, 1), - (726, 2), - (727, 2), - (727, 2), - ] + # the telemetry data for the previous packet. + expected_xfer_metrics = [(33, 1)] + for i in range(num_threads - 1): + expected_xfer_metrics.append( + (33 + len(telemetry_metrics( + metrics=2, bytes_sent=expected_xfer_metrics[i][0], packets_sent=expected_xfer_metrics[i][1] + )), 2)) for idx in range(num_threads): expected_message = "page.%d.views:123|g\ntimer.%d:123|ms" % (idx, idx)