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

example: flag variable used before parse - can't adjust bucket start, width using flag arguments #933

Closed
ii64 opened this issue Nov 8, 2021 · 1 comment · Fixed by #935

Comments

@ii64
Copy link

ii64 commented Nov 8, 2021

flag defined here
https://github.com/prometheus/client_golang/blob/679eb0d315d3bad8963927751537034476a52e25/examples/random/main.go
#L32-L38

used before calling flag.Parse() (derefencing from pointer), default value all the time

[]string{"service"},
)
// The same as above, but now as a histogram, and only for the normal
// distribution. The buckets are targeted to the parameters of the
// normal distribution, with 20 buckets centered on the mean, each
// half-sigma wide.
rpcDurationsHistogram = prometheus.NewHistogram(prometheus.HistogramOpts{
Name: "rpc_durations_histogram_seconds",
Help: "RPC latency distributions.",
Buckets: prometheus.LinearBuckets(*normMean-5**normDomain, .5**normDomain, 20),
})
)
func init() {

calling flag.Parse() (updates the flag value)

func main() {
flag.Parse()

beorn7 added a commit that referenced this issue Nov 10, 2021
Fixes #933.

Signed-off-by: beorn7 <beorn@grafana.com>
@beorn7
Copy link
Member

beorn7 commented Nov 10, 2021

Good catch. I simply moved everything into main() in #935.

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

Successfully merging a pull request may close this issue.

2 participants