-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Support extra custom query parameters in requests to Prometheus backend #6360
Support extra custom query parameters in requests to Prometheus backend #6360
Conversation
Signed-off-by: Alok Kumar Singh <dev.alok.singh123@gmail.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6360 +/- ##
==========================================
+ Coverage 96.14% 96.22% +0.08%
==========================================
Files 357 361 +4
Lines 20547 20623 +76
==========================================
+ Hits 19755 19845 +90
+ Misses 605 595 -10
+ Partials 187 183 -4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
pkg/prometheus/config/config.go
Outdated
LatencyUnit string `mapstructure:"latency_unit"` | ||
NormalizeCalls bool `mapstructure:"normalize_calls"` | ||
NormalizeDuration bool `mapstructure:"normalize_duration"` | ||
AdditionalParameters map[string]string `mapstructure:"additional_parameters"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AdditionalParameters map[string]string `mapstructure:"additional_parameters"` | |
ExtraQueryParams map[string]string `mapstructure:"extra_query_parameters"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a comment describing the purpose
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
||
promClient struct { | ||
api.Client | ||
params map[string]string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
params map[string]string | |
extraParams map[string]string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
||
// NewMetricsReader returns a new MetricsReader. | ||
func NewMetricsReader(cfg config.Configuration, logger *zap.Logger, tracer trace.TracerProvider) (*MetricsReader, error) { | ||
logger.Info("Creating metrics reader", zap.Any("configuration", cfg)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a good idea to log configuration as it may contain credentials
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code was already present before I refactored it. Removed it as suggested.
LatencyUnit: defaultLatencyUnit, | ||
NormalizeCalls: defaultNormalizeCalls, | ||
NormalizeDuration: defaultNormalizeCalls, | ||
AdditionalParameters: nil, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nil is the default value, no effect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Thanks. Removed it, as nil should be the default value.
Signed-off-by: Alok Kumar Singh <dev.alok.singh123@gmail.com>
|
||
query := u.Query() | ||
for k, v := range p.extraParams { | ||
query.Set(k, v) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why Set and not Add? We are not asked to replace params, only append them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Changed it to Add and updated test accordingly.
|
||
func createPromClient(logger *zap.Logger, cfg config.Configuration) (api.Client, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need logger here, and neither does getHTTPRoundTripper
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactored to remove logger from both. Thanks
|
||
logger := zap.NewNop() | ||
cfg := config.Configuration{ | ||
ServerURL: "http://localhost:1234", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ServerURL: "http://localhost:1234", | |
ServerURL: "http://localhost:1234?param1=value0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Co-authored-by: Yuri Shkuro <yurishkuro@users.noreply.github.com> Signed-off-by: Alok Kumar Singh <62210712+akstron@users.noreply.github.com>
Signed-off-by: Alok Kumar Singh <dev.alok.singh123@gmail.com>
90b055f
to
046b1b1
Compare
Signed-off-by: Alok Kumar Singh <dev.alok.singh123@gmail.com>
Co-authored-by: Yuri Shkuro <yurishkuro@users.noreply.github.com> Signed-off-by: Alok Kumar Singh <62210712+akstron@users.noreply.github.com>
Thanks! |
Which problem is this PR solving?
Description of the changes
promClient
to decorate url with additional parametersHow was this change tested?
TestCreatePromClientWithAdditionalParameters
Checklist
jaeger
:make lint test
jaeger-ui
:npm run lint
andnpm run test