jaegertracing / jaeger-lib Goto Github PK
View Code? Open in Web Editor NEWA collection of shared infrastructure libraries used by different components of Jaeger.
Home Page: https://github.com/uber/jaeger
License: Apache License 2.0
A collection of shared infrastructure libraries used by different components of Jaeger.
Home Page: https://github.com/uber/jaeger
License: Apache License 2.0
Improve rate limiter API.
Current rate limiter API does not have a way of checking when next credit will accrue.
Add method DetermineWaitTime to return the approximate time until next credit is accrued.
Currently tags are ignored in metrics/LocalBackend. That will make it impossible to use this local backend in unit tests that are sensitive to the tags. Address this by copying functionality from the metrics implementation in jaeger-client-go.
We've had situations where it would be useful to report histograms of non-timer values, e.g. a distribution of queue lengths, or the span sizes. Backends like Prometheus do support them.
The current metrics.Factory
only allows timers that are internally implemented as histograms.
Factory.Timer()
with Factory.Histogram(HistogramOptions{Name, Tags, Description, Buckets})
metrics.Timer(TimeOptions{HistogramOptions, Factory})
By default, the underlying prometheus client uses the following default buckets:
DefBuckets = []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10}
These values are tailored for measuring network latency, but also assume relatively low response times.
It should be possible to specify custom default buckets for the Histogram metric type that fit various use cases.
A function WithBuckets(buckets []float64)
is already exposed in the prometheus
package to define default buckets for the Factory
type.
However, when calling the factory's Histogram(options metrics.HistogramOptions)
method to build a new histogram, the default buckets that may have been set earlier are not taken into consideration.
Instead, only the buckets from the provided options
argument are used.
The factory Histogram
method should determine whether to use the configured default buckets or the buckets from the provided histogram options. If the options.buckets
slice is nil, the defaults must be used.
Please, let me know if all of this makes sense to you or have any additional questions.
I have also addressed the necessary changes in the code and I'm ready to open a PR if you agree.
There is a pending breaking change (#46). I suggest we take this opportunity to clean up the lib further. Specifically:
metric/go-kit/prometheus
package, since we have metrics/prometheus
implemented directly.metricstest
. (#46) (#51)PR #63 includes support for defining buckets on Timer and Histogram metric types. The buckets can be statically declared with the metrics and parsed on reflection.
Buckets for histogram metrics are being parsed, but currently not for timer durations.
Parse the timer durations.
How should the durations be expressed? For readability it would probably be best as a number + unit (e.g. 1s, 10m)
jaeger-lib currently has a constraint on prometheus/client_golang v0.8.0.
Now that prometheus/client_golang 1.0 was released on 2019-06-15,
https://github.com/prometheus/client_golang/releases, we should switch the constraint to 1.0 or newer.
yarpc-go depends on jaeger-client-go, which depends on jaeger-lib. So if jaeger-lib can update the dependency, it would help the other services update their dependency as well.
Support Go mod so that downstream projects can migrate to go mod
Trying to add the jaeger-lib into my project, but it locks the version of go-kit/kit to 0.5.0 in dep 'Gopkg.toml', since we also need the influxstatsd version inside the go-kit/kit which only exists above the version of 0.5.0.
So far cannot dep add the jaeger-lib into the project.
Is that ok just bump the version of go-kit/kit to current 0.9.0? Would the apis be broken?
Thank you very much.
Hi @yurishkuro - this repository doesn't have any releases tagged. Would you mind cutting a release so that our internal tools can pin to a reasonable semver range?
Histogram type has been added in #63 which enables buckets to be defined.
Expvar implementation does not currently respect the defined buckets.
Investigate how expvar impl can support the histogram buckets.
Investigate using https://github.com/uber-go/tally as the metrics API instead of having jaeger-lib/metrics
.
The APIs are similar, and tally supports writing to M3, Prometheus, statsd, and to multiple reporters out of the box.
##Open Questions
With #63 it is now possible to define Histograms with buckets - but also define duration based buckets for the Timer metric type.
The buckets are being used with the Tally Histogram type - but it appears the Tally Timer type does not enable buckets to be defined.
Either buckets will have to be ignored for Tally impl (with a warning being produced?), or the underlying representation should be changed to a Tally Histogram with DurationBuckets.
We would like to emit gauge updates with floating numbers (e.g. probabilities)
The gauge interface in jaeger-lib only supports int64
Lines 18 to 21 in 78a0e7f
Implementations like tally, prom, go-kit, influx and expvar support float64
gauges, but jaeger-lib
casts the int64
to a float64
value. Is there a reason for this?
jaeger-lib/metrics/prometheus/factory.go
Lines 230 to 232 in 78a0e7f
jaeger-lib/metrics/tally/metrics.go
Lines 49 to 51 in 78a0e7f
jaeger-lib/metrics/go-kit/metrics.go
Lines 49 to 51 in 78a0e7f
Update Gauge
to use float64
instead of int64
in jaeger-lib
3.0; alternatively jaeger-lib
can declare new types GaugeV2
, FactoryV2
, etc and create an adaptor.
Travis CI should use Go 1.11.1.
Travis CI uses Go 1.7 and Go 1.9, which are both outdated.
This will restrict us collect float number when use Gauge
# github.com/uber/jaeger-lib/metrics/prometheus ../../../github.com/uber/jaeger-lib/metrics/prometheus/factory.go:143:12: cannot use hv.WithLabelValues(f.tagsAsLabelValues(labelNames, tags)...) (type prometheus.Observer) as type prometheus.Histogram in field value: prometheus.Observer does not implement prometheus.Histogram (missing Collect method)
Error
app_1 | $ go run ./src/cmd/app/app.go
app_1 | # github.com/eldad87/go-boilerplate/vendor/github.com/uber/jaeger-lib/metrics/prometheus
app_1 | vendor/github.com/uber/jaeger-lib/metrics/prometheus/factory.go:143:3: cannot use hv.WithLabelValues(f.tagsAsLabelValues(labelNames, tags)...) (type prometheus.Observer) as type prometheus.Histogram in field value:
app_1 | prometheus.Observer does not implement prometheus.Histogram (missing Collect method)
git clone https://github.com/eldad87/go-boilerplate
docker-compose up --build
You'll see the error. Its a result of the following likes:
Is there a workaround?
Thanks!
Part of jaegertracing/jaeger#2691
The codahale/hdrhistogram repo has been transferred under the github HdrHstogram umbrella with the help from the original author in Sept 2020 (new repo url https://github.com/HdrHistogram/hdrhistogram-go). The main reasons are to group all implementations under the same roof and to provide more active contribution from the community as the original repository was archived several years ago.
Unfortunately such URL change will break go applications that depend on this library directly or indirectly, as discussed here.
The dependency URL should be modified to point to the new repository URL. The tag "v0.9.0" was applied at the point of transfer and will reflect the exact code that was frozen in the original repository.
If you are using Go modules, you can update to the exact point of transfter using the @v0.9.0 tag in your go get command.
go mod edit -replace github.com/codahale/hdrhistogram=github.com/HdrHistogram/[email protected]
The std lib usually uses MustXXX for panicing functions, so we should fix it now that we're doing a major bump:
func Init() error
func MustInit()
Attempting to enable client side prometheus metrics which blows up application code (See below). We need metrics to track dropped spans, etc.
Jaeger Go Client: v2.14.0
Jaeger Lib: v1.5.0
tl;dr Initializing new tracer with prometheus DefaultRegisterer
is panicking with panic: duplicate metrics collector registration attempted
.
Upon initializing tracer with the default prometheus registerer, by doing either:
factory := jprom.New(jprom.WithRegisterer(prometheus.DefaultRegisterer))
return cfg.NewTracer(
jaegercfg.Metrics(factory),
)
or (from example - both should be exactly the same):
factory := jprom.New()
return cfg.NewTracer(
jaegercfg.Metrics(factory),
)
I'm running into the following panic from the MustRegister
call from the metrics cache code which is used to initialize all metrics (counters, gauges, etc) via reflection from metrics defined here.
The error and conditions of the error is described in prometheus docs.
panic: duplicate metrics collector registration attempted
goroutine 1 [running]:
github.com/prometheus/client_golang/prometheus.(*Registry).MustRegister(0xc420083500, 0xc4203f9790, 0x1, 0x1)
/go/src/github.com/prometheus/client_golang/prometheus/registry.go:404 +0x9e
github.com/uber/jaeger-lib/metrics/prometheus.(*vectorCache).getOrMakeCounterVec(0xc420366300, 0x0, 0x0, 0x0, 0x0, 0xc4203e6640, 0xd, 0xc4203e6640, 0xd, 0x0, ...)
/go/src/github.com/uber/jaeger-lib/metrics/prometheus/cache.go:50 +0x213
github.com/uber/jaeger-lib/metrics/prometheus.(*Factory).Counter(0xc4203dc780, 0xc4203e6640, 0xd, 0xc4203663f0, 0xc42028b298, 0x2)
/go/src/github.com/uber/jaeger-lib/metrics/prometheus/factory.go:136 +0x186
github.com/uber/jaeger-lib/metrics.initMetrics(0xb098a0, 0xc420242c00, 0xd86f00, 0xc4203dc780, 0x0, 0x6, 0x6)
/go/src/github.com/uber/jaeger-lib/metrics/metrics.go:72 +0x43e
github.com/uber/jaeger-lib/metrics.Init(0xb098a0, 0xc420242c00, 0xd86f00, 0xc4203dc780, 0x0)
/go/src/github.com/uber/jaeger-lib/metrics/metrics.go:25 +0x57
github.com/uber/jaeger-client-go.NewMetrics(0xd86f00, 0xc4203dc730, 0x0, 0xd86f00)
/go/src/github.com/uber/jaeger-client-go/metrics.go:100 +0xa5
github.com/uber/jaeger-client-go/config.Configuration.NewTracer(0xc42003a074, 0xa, 0x0, 0x0, 0x0, 0x0, 0xc42025bc40, 0xc420366210, 0x0, 0x0, ...)
/go/src/github.com/uber/jaeger-client-go/config/config.go:178 +0xef
... application stack
Now our application code defines a ton of metrics that are already registered to the DefaultRegisterer
at this point but there is no way to tell if an already registered metrics' Desc
is clashing with jaeger client metrics or there is a bug in this reflection code which is re-registering one of the metrics twice (there is some hashing going on to create the cache key).
tl;dr: Use prometheus.Register
instead of prometheus.MustRegister
so errors can be logged or applied to use in business logic.
Couple of proposals:
1. Add test cases either here or in jaegertracing/jaeger-client-go to test for duplicate metrics registration (apologies if this is already done - i havent checked if these tests exist).
func (c *vectorCache) getOrMakeCounterVec(opts prometheus.CounterOpts, labelNames []string) (*prometheus.CounterVec, error) {
// ...
This can be done by switching from using c.registerer.MustRegister(cv)
(docs) to err := c.registerer.Register(cv)
(docs) and return the error to calling code. The error should also be logged to give more verbosity to application user. Obviously, repeated changes for getOrMakeGaugeVec
and getOrMakeHistogramVec
as well.
The reason for this second proposal is because its impossible to find the offending metric definition in hundreds/thousands of metrics defined both in user application and library code (jaeger-client-go). Logging the offending metric would at least let the user more information.
Should we skip registering an offending metric if registering the said metric with getOrMake*Vec
(Counter, Gauge, Timer) returns an error?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.