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

Expose UserAgent and fix User-Agent version source #2603

Merged
merged 2 commits into from
Sep 8, 2020

Conversation

rfratto
Copy link
Member

@rfratto rfratto commented Sep 8, 2020

This PR exposes UserAgent as an equivalent to a similar PR recently made for Prometheus, This allows importers (like grafana/agent) to customize the User-Agent to allow tracking which clients are sending data through Promtail.

As a secondary fix, this PR also changes the User Agent's version info to be pulled from github.com/prometheus/common/version rather than github.com/grafana/loki/pkg/build. grafana/agent has its own equivalent build package that sets the build version and needs a hack to ensure its own overrides take precedence. The clean fix is to get the version from the common dependency rather than the package responsible for setting the version globals.

…nt header

Promtail wasn't using github.com/prometheus/common/version for the
User-Agent header when obtaining the build version. Instead, it imported
github.com/grafana/loki/pkg/build which modifies the Prometheus version
package on init.

This causes problems for importers that also import and modify
github.com/prometheus/common/version with their own build information
(i.e., grafana/agent).

This PR changes Promtail to obtain the build info from the common
dependency to obtain the correct build information regardless of
how Promtail is being run.
@codecov-commenter
Copy link

Codecov Report

Merging #2603 into master will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2603      +/-   ##
==========================================
+ Coverage   62.92%   62.93%   +0.01%     
==========================================
  Files         169      169              
  Lines       15018    15018              
==========================================
+ Hits         9450     9452       +2     
+ Misses       4810     4809       -1     
+ Partials      758      757       -1     
Impacted Files Coverage Δ
pkg/promtail/client/client.go 85.15% <100.00%> (ø)
pkg/logql/evaluator.go 92.88% <0.00%> (+0.40%) ⬆️

Copy link
Collaborator

@slim-bean slim-bean left a comment

Choose a reason for hiding this comment

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

LGTM!

@rfratto rfratto merged commit ee67b9c into grafana:master Sep 8, 2020
@rfratto rfratto deleted the change-build-info branch September 8, 2020 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants