Set a custom user-agent for python client requests



3 years ago
3 years ago


(Reporter: mdoglio, Assigned: emorley)




(1 attachment)



3 years ago
So that we can look at the logs and tell who is using what.
An example of such user-agent could "treeherder-py/1.x.x".
Great idea :-)

Perhaps with optional project name that can be added?

eg: "treeherder-py/1.x.x Autophone"

Comment 2

3 years ago
Once I complete the work on the new auth system we will be able to identify a client via either the access token or the api key.
Yeah I was just thinking of the apache/gunicorn logs where the user presumably will be in the POST body, not the query string as is at present. But we should still be able to see the headers in the new relic transactions I guess :-)
Blocks: 1188398
Assignee: nobody → emorley
Priority: -- → P2
Summary: Set a custom user-agent in the client requests → Set a custom user-agent for python client requests
Created attachment 8643750 [details] [review]
Set a custom user-agent for python client requests

I'm open to suggestions for the client name given in the user agent. On that note, once we have the nodejs client in the Treeherder repo we may want to rename some of the python client directories, so having something consistent might make sense.
Attachment #8643750 - Flags: review?(wlachance)
Comment on attachment 8643750 [details] [review]
Set a custom user-agent for python client requests

This all looks fine to me. treeherder-pyclient sounds like a fine agent name.
Attachment #8643750 - Flags: review?(wlachance) → review+

Comment 6

3 years ago
Commits pushed to master at
Bug 1186918 - Python client: Make the version available at runtime

So we can use it in the User-Agent later. Uses the suggestion from:
Bug 1186918 - Python client: Use a constant for request headers

In the next commit we'll be adding a custom user agent header, which
will increase duplication. Therefore let's define the headers only once
to avoid this. The Content-Type header is redundant for post() since
one is set automatically when using the `json` param:
Bug 1186918 - Python client: List client name+version in the User-Agent

So we can more easily see which API requests are coming from which
client type, and know how many people are on older versions of the
Last Resolved: 3 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.