traefik/vendor/github.com/uber/jaeger-client-go/metrics.go

108 lines
6 KiB
Go
Raw Normal View History

2018-08-01 11:52:03 +00:00
// Copyright (c) 2017-2018 Uber Technologies, Inc.
2018-01-10 16:48:04 +00:00
//
2018-08-01 11:52:03 +00:00
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
2018-01-10 16:48:04 +00:00
//
2018-08-01 11:52:03 +00:00
// http://www.apache.org/licenses/LICENSE-2.0
2018-01-10 16:48:04 +00:00
//
2018-08-01 11:52:03 +00:00
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
2018-01-10 16:48:04 +00:00
package jaeger
import (
"github.com/uber/jaeger-lib/metrics"
)
// Metrics is a container of all stats emitted by Jaeger tracer.
type Metrics struct {
// Number of traces started by this tracer as sampled
2019-04-05 09:58:06 +00:00
TracesStartedSampled metrics.Counter `metric:"traces" tags:"state=started,sampled=y" help:"Number of traces started by this tracer as sampled"`
2018-01-10 16:48:04 +00:00
// Number of traces started by this tracer as not sampled
2019-04-05 09:58:06 +00:00
TracesStartedNotSampled metrics.Counter `metric:"traces" tags:"state=started,sampled=n" help:"Number of traces started by this tracer as not sampled"`
2018-01-10 16:48:04 +00:00
// Number of externally started sampled traces this tracer joined
2019-04-05 09:58:06 +00:00
TracesJoinedSampled metrics.Counter `metric:"traces" tags:"state=joined,sampled=y" help:"Number of externally started sampled traces this tracer joined"`
2018-01-10 16:48:04 +00:00
// Number of externally started not-sampled traces this tracer joined
2019-04-05 09:58:06 +00:00
TracesJoinedNotSampled metrics.Counter `metric:"traces" tags:"state=joined,sampled=n" help:"Number of externally started not-sampled traces this tracer joined"`
2018-01-10 16:48:04 +00:00
// Number of sampled spans started by this tracer
2019-04-05 09:58:06 +00:00
SpansStartedSampled metrics.Counter `metric:"started_spans" tags:"sampled=y" help:"Number of sampled spans started by this tracer"`
2018-01-10 16:48:04 +00:00
2018-08-01 11:52:03 +00:00
// Number of unsampled spans started by this tracer
2019-04-05 09:58:06 +00:00
SpansStartedNotSampled metrics.Counter `metric:"started_spans" tags:"sampled=n" help:"Number of unsampled spans started by this tracer"`
2018-01-10 16:48:04 +00:00
2018-08-01 11:52:03 +00:00
// Number of spans finished by this tracer
2019-04-05 09:58:06 +00:00
SpansFinished metrics.Counter `metric:"finished_spans" help:"Number of spans finished by this tracer"`
2018-01-10 16:48:04 +00:00
// Number of errors decoding tracing context
2019-04-05 09:58:06 +00:00
DecodingErrors metrics.Counter `metric:"span_context_decoding_errors" help:"Number of errors decoding tracing context"`
2018-01-10 16:48:04 +00:00
// Number of spans successfully reported
2019-04-05 09:58:06 +00:00
ReporterSuccess metrics.Counter `metric:"reporter_spans" tags:"result=ok" help:"Number of spans successfully reported"`
2018-01-10 16:48:04 +00:00
2018-08-01 11:52:03 +00:00
// Number of spans not reported due to a Sender failure
2019-04-05 09:58:06 +00:00
ReporterFailure metrics.Counter `metric:"reporter_spans" tags:"result=err" help:"Number of spans not reported due to a Sender failure"`
2018-01-10 16:48:04 +00:00
// Number of spans dropped due to internal queue overflow
2019-04-05 09:58:06 +00:00
ReporterDropped metrics.Counter `metric:"reporter_spans" tags:"result=dropped" help:"Number of spans dropped due to internal queue overflow"`
2018-01-10 16:48:04 +00:00
// Current number of spans in the reporter queue
2019-04-05 09:58:06 +00:00
ReporterQueueLength metrics.Gauge `metric:"reporter_queue_length" help:"Current number of spans in the reporter queue"`
2018-01-10 16:48:04 +00:00
// Number of times the Sampler succeeded to retrieve sampling strategy
2019-04-05 09:58:06 +00:00
SamplerRetrieved metrics.Counter `metric:"sampler_queries" tags:"result=ok" help:"Number of times the Sampler succeeded to retrieve sampling strategy"`
2018-08-01 11:52:03 +00:00
// Number of times the Sampler failed to retrieve sampling strategy
2019-04-05 09:58:06 +00:00
SamplerQueryFailure metrics.Counter `metric:"sampler_queries" tags:"result=err" help:"Number of times the Sampler failed to retrieve sampling strategy"`
2018-01-10 16:48:04 +00:00
// Number of times the Sampler succeeded to retrieve and update sampling strategy
2019-04-05 09:58:06 +00:00
SamplerUpdated metrics.Counter `metric:"sampler_updates" tags:"result=ok" help:"Number of times the Sampler succeeded to retrieve and update sampling strategy"`
2018-01-10 16:48:04 +00:00
// Number of times the Sampler failed to update sampling strategy
2019-04-05 09:58:06 +00:00
SamplerUpdateFailure metrics.Counter `metric:"sampler_updates" tags:"result=err" help:"Number of times the Sampler failed to update sampling strategy"`
2018-01-10 16:48:04 +00:00
2018-08-01 11:52:03 +00:00
// Number of times baggage was successfully written or updated on spans.
2019-04-05 09:58:06 +00:00
BaggageUpdateSuccess metrics.Counter `metric:"baggage_updates" tags:"result=ok" help:"Number of times baggage was successfully written or updated on spans"`
2018-08-01 11:52:03 +00:00
// Number of times baggage failed to write or update on spans.
2019-04-05 09:58:06 +00:00
BaggageUpdateFailure metrics.Counter `metric:"baggage_updates" tags:"result=err" help:"Number of times baggage failed to write or update on spans"`
2018-08-01 11:52:03 +00:00
// Number of times baggage was truncated as per baggage restrictions.
2019-04-05 09:58:06 +00:00
BaggageTruncate metrics.Counter `metric:"baggage_truncations" help:"Number of times baggage was truncated as per baggage restrictions"`
2018-08-01 11:52:03 +00:00
// Number of times baggage restrictions were successfully updated.
2019-04-05 09:58:06 +00:00
BaggageRestrictionsUpdateSuccess metrics.Counter `metric:"baggage_restrictions_updates" tags:"result=ok" help:"Number of times baggage restrictions were successfully updated"`
2018-08-01 11:52:03 +00:00
// Number of times baggage restrictions failed to update.
2019-04-05 09:58:06 +00:00
BaggageRestrictionsUpdateFailure metrics.Counter `metric:"baggage_restrictions_updates" tags:"result=err" help:"Number of times baggage restrictions failed to update"`
2018-08-01 11:52:03 +00:00
// Number of times debug spans were throttled.
2019-04-05 09:58:06 +00:00
ThrottledDebugSpans metrics.Counter `metric:"throttled_debug_spans" help:"Number of times debug spans were throttled"`
2018-08-01 11:52:03 +00:00
// Number of times throttler successfully updated.
2019-04-05 09:58:06 +00:00
ThrottlerUpdateSuccess metrics.Counter `metric:"throttler_updates" tags:"result=ok" help:"Number of times throttler successfully updated"`
2018-08-01 11:52:03 +00:00
// Number of times throttler failed to update.
2019-04-05 09:58:06 +00:00
ThrottlerUpdateFailure metrics.Counter `metric:"throttler_updates" tags:"result=err" help:"Number of times throttler failed to update"`
2018-01-10 16:48:04 +00:00
}
// NewMetrics creates a new Metrics struct and initializes it.
func NewMetrics(factory metrics.Factory, globalTags map[string]string) *Metrics {
m := &Metrics{}
2019-04-05 09:58:06 +00:00
// TODO the namespace "jaeger" should be configurable
metrics.MustInit(m, factory.Namespace(metrics.NSOptions{Name: "jaeger"}).Namespace(metrics.NSOptions{Name: "tracer"}), globalTags)
2018-01-10 16:48:04 +00:00
return m
}
// NewNullMetrics creates a new Metrics struct that won't report any metrics.
func NewNullMetrics() *Metrics {
return NewMetrics(metrics.NullFactory, nil)
}