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

Add sampler type tag to collector ingestion metrics #1576

Merged
merged 9 commits into from
Jun 6, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
remove remote sampler type
Signed-off-by: Jude Wang <judew@uber.com>
  • Loading branch information
Jude Wang committed Jun 5, 2019
commit 6eeae797f08235363eded7bebca2afef3e467418
9 changes: 2 additions & 7 deletions cmd/collector/app/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,16 @@ const (

samplerTypeKey = "sampler_type"
samplerTypeConst = "const"
samplerTypeRemote = "remote"
samplerTypeProbabilistic = "probabilistic"
samplerTypeRateLimiting = "ratelimiting"
samplerTypeLowerBound = "lowerbound"
samplerTypeUnknown = "unknown"
// types of samplers: const, remote, probabilistic, ratelimiting, lowerbound
numOfSamplerTypes = 5
// types of samplers: const, probabilistic, ratelimiting, lowerbound
numOfSamplerTypes = 4

concatenation = "$_$"

otherServicesConstSampler = otherServices + concatenation + samplerTypeConst
otherServicesRemoteSampler = otherServices + concatenation + samplerTypeRemote
otherServicesProbabilisticSampler = otherServices + concatenation + samplerTypeProbabilistic
otherServicesRateLimitingSampler = otherServices + concatenation + samplerTypeRateLimiting
otherServicesLowerBoundSampler = otherServices + concatenation + samplerTypeLowerBound
Expand Down Expand Up @@ -195,7 +193,6 @@ func newTraceCountsOtherServices(factory metrics.Factory, category string, isDeb
otherServicesLowerBoundSampler: factory.Counter(metrics.Options{Name: category, Tags: map[string]string{"svc": otherServices, "debug": isDebug, samplerTypeKey: samplerTypeLowerBound}}),
otherServicesProbabilisticSampler: factory.Counter(metrics.Options{Name: category, Tags: map[string]string{"svc": otherServices, "debug": isDebug, samplerTypeKey: samplerTypeProbabilistic}}),
otherServicesRateLimitingSampler: factory.Counter(metrics.Options{Name: category, Tags: map[string]string{"svc": otherServices, "debug": isDebug, samplerTypeKey: samplerTypeRateLimiting}}),
otherServicesRemoteSampler: factory.Counter(metrics.Options{Name: category, Tags: map[string]string{"svc": otherServices, "debug": isDebug, samplerTypeKey: samplerTypeRemote}}),
otherServicesUnknownSampler: factory.Counter(metrics.Options{Name: category, Tags: map[string]string{"svc": otherServices, "debug": isDebug, samplerTypeKey: samplerTypeUnknown}}),
}
}
Expand Down Expand Up @@ -309,8 +306,6 @@ func (m *traceCountsBySvc) countByServiceName(serviceName string, isDebug bool,
switch samplerType {
case samplerTypeConst:
counter = counts[otherServicesConstSampler]
case samplerTypeRemote:
counter = counts[otherServicesRemoteSampler]
case samplerTypeLowerBound:
counter = counts[otherServicesLowerBoundSampler]
case samplerTypeProbabilistic:
Expand Down
6 changes: 2 additions & 4 deletions cmd/collector/app/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,19 @@ func TestNewTraceCountsBySvc(t *testing.T) {
assert.EqualValues(t, 1, counters["not_on_my_level|debug=false|sampler_type=unknown|svc=leela"])
assert.EqualValues(t, 2, counters["not_on_my_level|debug=false|sampler_type=unknown|svc=other-services"])

metrics.countByServiceName("zoidberg", true, "remote")
metrics.countByServiceName("bender", true, "const")
metrics.countByServiceName("bender", true, "probabilistic")
metrics.countByServiceName("leela", true, "probabilistic")
metrics.countByServiceName("fry", true, "ratelimiting")
metrics.countByServiceName("leela", true, "remote")
metrics.countByServiceName("fry", true, "const")
metrics.countByServiceName("elzar", true, "lowerbound")
metrics.countByServiceName("url", true, "unknown")

counters, _ = baseMetrics.Backend.Snapshot()
assert.EqualValues(t, 1, counters["not_on_my_level|debug=true|sampler_type=remote|svc=zoidberg"])
assert.EqualValues(t, 1, counters["not_on_my_level|debug=true|sampler_type=const|svc=bender"])
assert.EqualValues(t, 1, counters["not_on_my_level|debug=true|sampler_type=probabilistic|svc=bender"])
assert.EqualValues(t, 1, counters["not_on_my_level|debug=true|sampler_type=probabilistic|svc=other-services"])
assert.EqualValues(t, 1, counters["not_on_my_level|debug=true|sampler_type=ratelimiting|svc=other-services"])
assert.EqualValues(t, 1, counters["not_on_my_level|debug=true|sampler_type=remote|svc=other-services"])
assert.EqualValues(t, 1, counters["not_on_my_level|debug=true|sampler_type=const|svc=other-services"])
assert.EqualValues(t, 1, counters["not_on_my_level|debug=true|sampler_type=lowerbound|svc=other-services"])
assert.EqualValues(t, 1, counters["not_on_my_level|debug=true|sampler_type=unknown|svc=other-services"])
Expand Down