Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

Normalize metric names and tags #222

Merged
merged 9 commits into from
Nov 27, 2017
Merged

Normalize metric names and tags #222

merged 9 commits into from
Nov 27, 2017

Conversation

yurishkuro
Copy link
Member

When used with Prometheus backend current metrics cannot be initialized because they use the same names (e.g. "spans") with different dimensions of the tags (e.g. "group, state" vs. "group, sampled").

This change splits different sets of metrics by name, so that a single name uses the same dimensions of tags.

@codecov
Copy link

codecov bot commented Nov 12, 2017

Codecov Report

Merging #222 into master will decrease coverage by 0.24%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #222      +/-   ##
==========================================
- Coverage   81.99%   81.74%   -0.25%     
==========================================
  Files          51       51              
  Lines        3226     3226              
==========================================
- Hits         2645     2637       -8     
- Misses        457      464       +7     
- Partials      124      125       +1
Impacted Files Coverage Δ
metrics.go 100% <100%> (ø) ⬆️
tracer.go 88.16% <100%> (-1.68%) ⬇️
tracer_options.go 73.52% <0%> (-5.89%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fc11c1a...14c449e. Read the comment docs.

@NeoCN
Copy link

NeoCN commented Nov 12, 2017

encounter with panic: duplicate metrics collector registration attempted. when use prometheus on client side, can not wait to see this pr and jaegertracing/jaeger-lib#29 being merged.

README.md Outdated
stats := // create StatsReporter implementation
tracer := config.Tracing.New("your-service-name", stats)
import (
"github.com/prometheus/client_golang/prometheus"
Copy link
Contributor

Choose a reason for hiding this comment

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

spacing is funky

HTTP Header `jaeger-baggage` on a request
The OpenTracing spec allows for [baggage][baggage], which are key value pairs that are added
to the span context and propagated throughout the trace. An external process can inject baggage
by setting the special HTTP Header `jaeger-baggage` on a request:
Copy link
Contributor

Choose a reason for hiding this comment

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

we should have a TODO to update documentation so that users are aware of https://github.com/jaegertracing/jaeger-client-go/blob/master/header.go#L30

Copy link
Member Author

Choose a reason for hiding this comment

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

metrics.go Outdated
@@ -33,16 +33,16 @@ type Metrics struct {
TracesJoinedNotSampled metrics.Counter `metric:"traces" tags:"state=joined,sampled=n"`

// Number of sampled spans started by this tracer
SpansStarted metrics.Counter `metric:"spans" tags:"group=lifecycle,state=started"`
SpansStarted metrics.Counter `metric:"spans-by-lifecycle" tags:"state=started"`
Copy link
Contributor

Choose a reason for hiding this comment

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

how bout "spans-lifecycle"

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm open to suggestions how to make the naming more consistent across the board.

One other thing I would like to do is to use underscore instead of dash as a separator. Dash is not valid in Prometheus.

@yurishkuro
Copy link
Member Author

@black-adder please take a look at the new naming https://github.com/jaegertracing/jaeger-client-go/pull/222/files#diff-c47669012d7664f9cbee69c67bf8bedfR36

Once we agree on it I will update the tests.


// Number of times baggage restrictions failed to update.
BaggageRestrictionsUpdateFailure metrics.Counter `metric:"baggage-restrictions-update" tags:"result=err"`
BaggageRestrictionsUpdateFailure metrics.Counter `metric:"baggage_restrictions_updates" tags:"result=err"`
}
Copy link
Member Author

Choose a reason for hiding this comment

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

@pavolloffay @objectiser penny for your thoughts.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 - I assume the names will be consistent across all clients?

Copy link
Member Author

Choose a reason for hiding this comment

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

As much as possible. I don't think we have tag-based APIs in Python and Node.js clients.

Another option would be to drop tags completely and just encode them in the name, e.g. traces_started_sampled. It makes it harder to aggregate if say you don't care about the "is_sampled" dimension.

Copy link
Contributor

Choose a reason for hiding this comment

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

Better to have tags - is there any reason they can't be added to python and node clients?

@NeoCN
Copy link

NeoCN commented Nov 21, 2017

Waiting for this PR, any update?

@yurishkuro
Copy link
Member Author

eta Nov 27

Yuri Shkuro added 4 commits November 21, 2017 13:54
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
README.md Outdated
tracer := config.Tracing.New("your-service-name", stats)
import (
"github.com/uber/jaeger-lib/metrics/prometheus"
"github.com/uber/jaeger-client-go/config"
Copy link
Contributor

Choose a reason for hiding this comment

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

omg imports

metrics.go Outdated
@@ -33,63 +33,61 @@ type Metrics struct {
TracesJoinedNotSampled metrics.Counter `metric:"traces" tags:"state=joined,sampled=n"`

// Number of sampled spans started by this tracer
SpansStarted metrics.Counter `metric:"spans" tags:"group=lifecycle,state=started"`
SpansStartedSampled metrics.Counter `metric:"spans_started" tags:"sampled=y"`
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer sampled=true and sampled=false

metrics_test.go Outdated
Tags: map[string]string{"lib": "jaeger"},
Value: 11,
},
)
}

// TestNewPrometheusMetrics ensures that the metrics do not have conflicting dimensions and will work with Prometheus.
func TestNewPrometheusMetrics(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

remind me, will this pull in all of prometheus for service owners even if they don't use prometheus metrics?

Copy link
Member Author

Choose a reason for hiding this comment

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

I moved it to testImport: in glide. Another alternative is to move the test to a sub-package.

metrics.go Outdated

// Number of times the Sampler succeeded to retrieve and update sampling strategy
SamplerUpdated metrics.Counter `metric:"sampler" tags:"state=updated"`
SamplerUpdated metrics.Counter `metric:"sampler_updated"`
Copy link
Contributor

Choose a reason for hiding this comment

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

"sampler_updates, result=ok" and "sampler_updates, result=err" to keep in line with the baggage stuff and we can update sampler_query_failures as you have.

Copy link
Member Author

Choose a reason for hiding this comment

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

Still leaves sampler_retrieved and baggage_truncated ending in a verb.

Also, if we want to convert everything to end with a noun, we may consider s/spans_started/started_spans/ (finished_spans, etc.)

Yuri Shkuro added 2 commits November 21, 2017 19:52
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
metrics.go Outdated
@@ -33,40 +33,40 @@ type Metrics struct {
TracesJoinedNotSampled metrics.Counter `metric:"traces" tags:"state=joined,sampled=n"`

// Number of sampled spans started by this tracer
SpansStartedSampled metrics.Counter `metric:"spans_started" tags:"sampled=y"`
SpansStartedSampled metrics.Counter `metric:"started_spans" tags:"sampled=y"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious why this change? and similarly for finished_spans

Copy link
Member Author

Choose a reason for hiding this comment

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

wanted to normalize all names to end with noun

Yuri Shkuro added 2 commits November 27, 2017 14:51
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants