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

Allow overriding the default User-Agent header #356

Closed
dgnorton opened this issue Sep 15, 2022 · 7 comments · Fixed by #358
Closed

Allow overriding the default User-Agent header #356

dgnorton opened this issue Sep 15, 2022 · 7 comments · Fixed by #358
Labels
enhancement New feature or request
Milestone

Comments

@dgnorton
Copy link

Proposal:
Add a feature allowing users of this client library to override the default influxdb-client-go User-Agent HTTP header. This would make it easier to understand which apps are making which requests. E.g., currently, if App1 and App2 use this client, the UA coming from both will read influxdb-client-go. Allowing the apps to override the UA would make it easier to distinguish between the two.

Current behavior:
User-Agent header is hard coded to influxdb-client-go

Desired behavior:
Add 2 options for users:

  1. Add method to set a field or two (AppName and Version?) for their User-Agent. The client would then construct a User-Agent. Something like influxdb-client-go/2.3 AppName/Version. Mark this in the docs as recommended.
  2. Add a second method that allows completely overriding the User-Agent.
@sranka
Copy link
Contributor

sranka commented Sep 15, 2022

I think that it is a good idea (and already good practice in other databases) to have a simple option to set application name. My preference would be to represent it as one string with documentation saying that it should distinguish applications that connect to the same InfluxDB. The same option should be better present in all InfluxDB clients (python, java, js ...).

It is already possible to customize anything in the request, including User-Agent, see #314.

@dgnorton
Copy link
Author

I think that is fine. Also, maybe setting the application name should be required? That would break backwards compatibility but would be a simple update for clients and would encourage a best practice.

@vlastahajek
Copy link
Contributor

Ok. When an application name will be set, it will be added to the end of the current UA string. E.g.: influxdb-client-go/2.10.0 (linux; amd64) IoTHub/1.10

@vlastahajek vlastahajek added this to the v2.11.0 milestone Sep 16, 2022
@vlastahajek vlastahajek added the enhancement New feature or request label Sep 16, 2022
@lesam
Copy link
Contributor

lesam commented Sep 16, 2022

I don't love breaking a ton of users for this - maybe an annoying log message if the application name is unset would be enough?

@lesam
Copy link
Contributor

lesam commented Sep 16, 2022

Also an example of how to set custom headers with Doer might be a good addition to the docs, if it's not there already.

@vlastahajek
Copy link
Contributor

vlastahajek commented Sep 16, 2022

I don't love breaking a ton of users for this - maybe an annoying log message if the application name is unset would be enough?

👍 That's exactly what I wanted to propose - a warning message to set application.

@sspaink sspaink modified the milestones: v2.11.0, v2.12.0 Sep 29, 2022
@bednar
Copy link
Contributor

bednar commented Oct 7, 2022

jfyi... the Mongo uses AppName configuration options - https://pkg.go.dev/go.mongodb.org/mongo-driver@v1.10.3/mongo/options#ClientOptions.SetAppName

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants