Skip to content

Improve user-agent header to include telemetry information#583

Merged
bkabrda merged 3 commits intomasterfrom
slavek.kabrda/user-agent-for-telemetry
Jul 2, 2020
Merged

Improve user-agent header to include telemetry information#583
bkabrda merged 3 commits intomasterfrom
slavek.kabrda/user-agent-for-telemetry

Conversation

@bkabrda
Copy link
Copy Markdown

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

passenv = DD_TEST_CLIENT*
usedevelop = true
deps =
!integration: mock
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Author

bkabrda commented Jul 2, 2020

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 2 pipeline(s).

@bkabrda
Copy link
Copy Markdown
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
Copy Markdown
Author

bkabrda commented Jul 2, 2020

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 2 pipeline(s).

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