1// Copyright (c) 2017-2018 Uber Technologies, Inc. 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15package jaeger 16 17import ( 18 "github.com/uber/jaeger-lib/metrics" 19) 20 21// Metrics is a container of all stats emitted by Jaeger tracer. 22type Metrics struct { 23 // Number of traces started by this tracer as sampled 24 TracesStartedSampled metrics.Counter `metric:"traces" tags:"state=started,sampled=y" help:"Number of traces started by this tracer as sampled"` 25 26 // Number of traces started by this tracer as not sampled 27 TracesStartedNotSampled metrics.Counter `metric:"traces" tags:"state=started,sampled=n" help:"Number of traces started by this tracer as not sampled"` 28 29 // Number of traces started by this tracer with delayed sampling 30 TracesStartedDelayedSampling metrics.Counter `metric:"traces" tags:"state=started,sampled=n" help:"Number of traces started by this tracer with delayed sampling"` 31 32 // Number of externally started sampled traces this tracer joined 33 TracesJoinedSampled metrics.Counter `metric:"traces" tags:"state=joined,sampled=y" help:"Number of externally started sampled traces this tracer joined"` 34 35 // Number of externally started not-sampled traces this tracer joined 36 TracesJoinedNotSampled metrics.Counter `metric:"traces" tags:"state=joined,sampled=n" help:"Number of externally started not-sampled traces this tracer joined"` 37 38 // Number of sampled spans started by this tracer 39 SpansStartedSampled metrics.Counter `metric:"started_spans" tags:"sampled=y" help:"Number of spans started by this tracer as sampled"` 40 41 // Number of not sampled spans started by this tracer 42 SpansStartedNotSampled metrics.Counter `metric:"started_spans" tags:"sampled=n" help:"Number of spans started by this tracer as not sampled"` 43 44 // Number of spans with delayed sampling started by this tracer 45 SpansStartedDelayedSampling metrics.Counter `metric:"started_spans" tags:"sampled=delayed" help:"Number of spans started by this tracer with delayed sampling"` 46 47 // Number of spans finished by this tracer 48 SpansFinishedSampled metrics.Counter `metric:"finished_spans" tags:"sampled=y" help:"Number of sampled spans finished by this tracer"` 49 50 // Number of spans finished by this tracer 51 SpansFinishedNotSampled metrics.Counter `metric:"finished_spans" tags:"sampled=n" help:"Number of not-sampled spans finished by this tracer"` 52 53 // Number of spans finished by this tracer 54 SpansFinishedDelayedSampling metrics.Counter `metric:"finished_spans" tags:"sampled=delayed" help:"Number of spans with delayed sampling finished by this tracer"` 55 56 // Number of errors decoding tracing context 57 DecodingErrors metrics.Counter `metric:"span_context_decoding_errors" help:"Number of errors decoding tracing context"` 58 59 // Number of spans successfully reported 60 ReporterSuccess metrics.Counter `metric:"reporter_spans" tags:"result=ok" help:"Number of spans successfully reported"` 61 62 // Number of spans not reported due to a Sender failure 63 ReporterFailure metrics.Counter `metric:"reporter_spans" tags:"result=err" help:"Number of spans not reported due to a Sender failure"` 64 65 // Number of spans dropped due to internal queue overflow 66 ReporterDropped metrics.Counter `metric:"reporter_spans" tags:"result=dropped" help:"Number of spans dropped due to internal queue overflow"` 67 68 // Current number of spans in the reporter queue 69 ReporterQueueLength metrics.Gauge `metric:"reporter_queue_length" help:"Current number of spans in the reporter queue"` 70 71 // Number of times the Sampler succeeded to retrieve sampling strategy 72 SamplerRetrieved metrics.Counter `metric:"sampler_queries" tags:"result=ok" help:"Number of times the Sampler succeeded to retrieve sampling strategy"` 73 74 // Number of times the Sampler failed to retrieve sampling strategy 75 SamplerQueryFailure metrics.Counter `metric:"sampler_queries" tags:"result=err" help:"Number of times the Sampler failed to retrieve sampling strategy"` 76 77 // Number of times the Sampler succeeded to retrieve and update sampling strategy 78 SamplerUpdated metrics.Counter `metric:"sampler_updates" tags:"result=ok" help:"Number of times the Sampler succeeded to retrieve and update sampling strategy"` 79 80 // Number of times the Sampler failed to update sampling strategy 81 SamplerUpdateFailure metrics.Counter `metric:"sampler_updates" tags:"result=err" help:"Number of times the Sampler failed to update sampling strategy"` 82 83 // Number of times baggage was successfully written or updated on spans. 84 BaggageUpdateSuccess metrics.Counter `metric:"baggage_updates" tags:"result=ok" help:"Number of times baggage was successfully written or updated on spans"` 85 86 // Number of times baggage failed to write or update on spans. 87 BaggageUpdateFailure metrics.Counter `metric:"baggage_updates" tags:"result=err" help:"Number of times baggage failed to write or update on spans"` 88 89 // Number of times baggage was truncated as per baggage restrictions. 90 BaggageTruncate metrics.Counter `metric:"baggage_truncations" help:"Number of times baggage was truncated as per baggage restrictions"` 91 92 // Number of times baggage restrictions were successfully updated. 93 BaggageRestrictionsUpdateSuccess metrics.Counter `metric:"baggage_restrictions_updates" tags:"result=ok" help:"Number of times baggage restrictions were successfully updated"` 94 95 // Number of times baggage restrictions failed to update. 96 BaggageRestrictionsUpdateFailure metrics.Counter `metric:"baggage_restrictions_updates" tags:"result=err" help:"Number of times baggage restrictions failed to update"` 97 98 // Number of times debug spans were throttled. 99 ThrottledDebugSpans metrics.Counter `metric:"throttled_debug_spans" help:"Number of times debug spans were throttled"` 100 101 // Number of times throttler successfully updated. 102 ThrottlerUpdateSuccess metrics.Counter `metric:"throttler_updates" tags:"result=ok" help:"Number of times throttler successfully updated"` 103 104 // Number of times throttler failed to update. 105 ThrottlerUpdateFailure metrics.Counter `metric:"throttler_updates" tags:"result=err" help:"Number of times throttler failed to update"` 106} 107 108// NewMetrics creates a new Metrics struct and initializes it. 109func NewMetrics(factory metrics.Factory, globalTags map[string]string) *Metrics { 110 m := &Metrics{} 111 // TODO the namespace "jaeger" should be configurable 112 metrics.MustInit(m, factory.Namespace(metrics.NSOptions{Name: "jaeger"}).Namespace(metrics.NSOptions{Name: "tracer"}), globalTags) 113 return m 114} 115 116// NewNullMetrics creates a new Metrics struct that won't report any metrics. 117func NewNullMetrics() *Metrics { 118 return NewMetrics(metrics.NullFactory, nil) 119} 120