Skip to content

[statsd] Always terminate packets with newline#685

Merged
sgnn7 merged 1 commit intomasterfrom
sgnn7/add-newline-metric-termination
Aug 30, 2021
Merged

[statsd] Always terminate packets with newline#685
sgnn7 merged 1 commit intomasterfrom
sgnn7/add-newline-metric-termination

Conversation

@sgnn7
Copy link
Copy Markdown
Contributor

@sgnn7 sgnn7 commented Aug 30, 2021

What does this PR do?

Adds newline (\n) to all packets sent to the DogStatsd endpoint

Description of the Change

To prevent processing of packets that are incomplete by the time they
reach the server for whatever reason, we now add a newline to end of
all of our packets so that the server can recognize and discard partial
messages/metrics.

Alternate Designs

Possible Drawbacks

One character additionally sent with each packet (minimal impact on buffered clients)

Verification Process

  • Run the test suite (python3 -m unittest -vvv tests.unit.dogstatsd.test_statsd.TestDogStatsd)

Alternatively:

  • Start a fake statsd server on a separate terminal (./tests/util/fake_statsd_server.py UDP)
  • Send a metric and ensure it has a newline at the end on the server's received packet output:
$ python3
>>> from datadog import initialize,statsd
>>> initialize(statsd_host="localhost", statsd_port=<port_from_server>)
>>> statsd.increment("home.page.hits")

Additional Notes

Release Notes

N/A

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.

To prevent processing of packets that are incomplete by the time they
reach the server for whatever reason, we now add a newline to end of
all of our packets so that the server can recognize and discard partial
messages/metrics.
@sgnn7 sgnn7 added resource/dogstatsd changelog/Changed Changed features results into a major version bump severity/normal Normal severity issue labels Aug 30, 2021
@sgnn7 sgnn7 added this to the Next milestone Aug 30, 2021
@sgnn7 sgnn7 requested review from a team as code owners August 30, 2021 20:31
@sgnn7 sgnn7 self-assigned this Aug 30, 2021
@sgnn7
Copy link
Copy Markdown
Contributor Author

sgnn7 commented Aug 30, 2021

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 2 pipeline(s).

Copy link
Copy Markdown
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.

👍 👍

@sgnn7 sgnn7 merged commit 5f25c44 into master Aug 30, 2021
@sgnn7 sgnn7 deleted the sgnn7/add-newline-metric-termination branch August 30, 2021 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/Changed Changed features results into a major version bump resource/dogstatsd severity/normal Normal severity issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants