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

Improve user-agent header to include telemetry information #583

Merged
merged 3 commits into from
Jul 2, 2020

Conversation

bkabrda
Copy link
Contributor

@bkabrda bkabrda commented Jul 1, 2020

What does this PR do?

Makes the user-agent header more useful.

Description of the Change

Alternate Designs

Possible Drawbacks

Verification Process

Additional Notes

Release Notes

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.

@bkabrda bkabrda added the changelog/Added Added features results into a minor version bump label Jul 1, 2020
@bkabrda bkabrda requested a review from a team as a code owner July 1, 2020 17:39
Copy link
Contributor

@nmuesch nmuesch left a comment

Choose a reason for hiding this comment

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

Looks good, two quick comments. Thanks!

def test_user_agent(self, dog):
_, resp = dog.api_client.APIClient.submit('GET', 'validate')
assert re.match(r'^datadogpy\/[^\s]+ \(python [^\s]+; os [^\s]+; arch [^\s]+\)$', resp.request.headers['User-Agent'])
resp.request.headers['User-Agent']
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this line needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, forgotten debugging line, sorry. Will remove.

@@ -11,9 +11,9 @@ envlist =
passenv = DD_TEST_CLIENT*
usedevelop = true
deps =
!integration: mock
Copy link
Contributor

Choose a reason for hiding this comment

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

I think if we move the user agent test to tests/unit instead of tests/integration we wouldn't need to change deps.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, but the whole unittest suite as it is set up now replaces the RequestClient._session, so we'd have to create a completely different setup just because of this one specific test. I don't mind doing that, but this is just simpler (plus it tests the real thing).

@bkabrda
Copy link
Contributor Author

bkabrda commented Jul 2, 2020

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@bkabrda
Copy link
Contributor Author

bkabrda commented Jul 2, 2020

Hmm, I have also realized that there's a theoretical possibility that someone uses the URLFetchClient, so I'll also make sure to correct the User-Agent header for it.

@bkabrda
Copy link
Contributor Author

bkabrda commented Jul 2, 2020

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

Copy link
Contributor

@zippolyte zippolyte left a comment

Choose a reason for hiding this comment

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

LGTM

@bkabrda bkabrda merged commit e9900e3 into master Jul 2, 2020
@bkabrda bkabrda deleted the slavek.kabrda/user-agent-for-telemetry branch July 2, 2020 08:13
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants