metrics.go 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. package jaeger
  15. import (
  16. "github.com/uber/jaeger-lib/metrics"
  17. )
  18. // Metrics is a container of all stats emitted by Jaeger tracer.
  19. type Metrics struct {
  20. // Number of traces started by this tracer as sampled
  21. TracesStartedSampled metrics.Counter `metric:"traces" tags:"state=started,sampled=y" help:"Number of traces started by this tracer as sampled"`
  22. // Number of traces started by this tracer as not sampled
  23. TracesStartedNotSampled metrics.Counter `metric:"traces" tags:"state=started,sampled=n" help:"Number of traces started by this tracer as not sampled"`
  24. // Number of traces started by this tracer with delayed sampling
  25. TracesStartedDelayedSampling metrics.Counter `metric:"traces" tags:"state=started,sampled=n" help:"Number of traces started by this tracer with delayed sampling"`
  26. // Number of externally started sampled traces this tracer joined
  27. TracesJoinedSampled metrics.Counter `metric:"traces" tags:"state=joined,sampled=y" help:"Number of externally started sampled traces this tracer joined"`
  28. // Number of externally started not-sampled traces this tracer joined
  29. TracesJoinedNotSampled metrics.Counter `metric:"traces" tags:"state=joined,sampled=n" help:"Number of externally started not-sampled traces this tracer joined"`
  30. // Number of sampled spans started by this tracer
  31. SpansStartedSampled metrics.Counter `metric:"started_spans" tags:"sampled=y" help:"Number of spans started by this tracer as sampled"`
  32. // Number of not sampled spans started by this tracer
  33. SpansStartedNotSampled metrics.Counter `metric:"started_spans" tags:"sampled=n" help:"Number of spans started by this tracer as not sampled"`
  34. // Number of spans with delayed sampling started by this tracer
  35. SpansStartedDelayedSampling metrics.Counter `metric:"started_spans" tags:"sampled=delayed" help:"Number of spans started by this tracer with delayed sampling"`
  36. // Number of spans finished by this tracer
  37. SpansFinishedSampled metrics.Counter `metric:"finished_spans" tags:"sampled=y" help:"Number of sampled spans finished by this tracer"`
  38. // Number of spans finished by this tracer
  39. SpansFinishedNotSampled metrics.Counter `metric:"finished_spans" tags:"sampled=n" help:"Number of not-sampled spans finished by this tracer"`
  40. // Number of spans finished by this tracer
  41. SpansFinishedDelayedSampling metrics.Counter `metric:"finished_spans" tags:"sampled=delayed" help:"Number of spans with delayed sampling finished by this tracer"`
  42. // Number of errors decoding tracing context
  43. DecodingErrors metrics.Counter `metric:"span_context_decoding_errors" help:"Number of errors decoding tracing context"`
  44. // Number of spans successfully reported
  45. ReporterSuccess metrics.Counter `metric:"reporter_spans" tags:"result=ok" help:"Number of spans successfully reported"`
  46. // Number of spans not reported due to a Sender failure
  47. ReporterFailure metrics.Counter `metric:"reporter_spans" tags:"result=err" help:"Number of spans not reported due to a Sender failure"`
  48. // Number of spans dropped due to internal queue overflow
  49. ReporterDropped metrics.Counter `metric:"reporter_spans" tags:"result=dropped" help:"Number of spans dropped due to internal queue overflow"`
  50. // Current number of spans in the reporter queue
  51. ReporterQueueLength metrics.Gauge `metric:"reporter_queue_length" help:"Current number of spans in the reporter queue"`
  52. // Number of times the Sampler succeeded to retrieve sampling strategy
  53. SamplerRetrieved metrics.Counter `metric:"sampler_queries" tags:"result=ok" help:"Number of times the Sampler succeeded to retrieve sampling strategy"`
  54. // Number of times the Sampler failed to retrieve sampling strategy
  55. SamplerQueryFailure metrics.Counter `metric:"sampler_queries" tags:"result=err" help:"Number of times the Sampler failed to retrieve sampling strategy"`
  56. // Number of times the Sampler succeeded to retrieve and update sampling strategy
  57. SamplerUpdated metrics.Counter `metric:"sampler_updates" tags:"result=ok" help:"Number of times the Sampler succeeded to retrieve and update sampling strategy"`
  58. // Number of times the Sampler failed to update sampling strategy
  59. SamplerUpdateFailure metrics.Counter `metric:"sampler_updates" tags:"result=err" help:"Number of times the Sampler failed to update sampling strategy"`
  60. // Number of times baggage was successfully written or updated on spans.
  61. BaggageUpdateSuccess metrics.Counter `metric:"baggage_updates" tags:"result=ok" help:"Number of times baggage was successfully written or updated on spans"`
  62. // Number of times baggage failed to write or update on spans.
  63. BaggageUpdateFailure metrics.Counter `metric:"baggage_updates" tags:"result=err" help:"Number of times baggage failed to write or update on spans"`
  64. // Number of times baggage was truncated as per baggage restrictions.
  65. BaggageTruncate metrics.Counter `metric:"baggage_truncations" help:"Number of times baggage was truncated as per baggage restrictions"`
  66. // Number of times baggage restrictions were successfully updated.
  67. BaggageRestrictionsUpdateSuccess metrics.Counter `metric:"baggage_restrictions_updates" tags:"result=ok" help:"Number of times baggage restrictions were successfully updated"`
  68. // Number of times baggage restrictions failed to update.
  69. BaggageRestrictionsUpdateFailure metrics.Counter `metric:"baggage_restrictions_updates" tags:"result=err" help:"Number of times baggage restrictions failed to update"`
  70. // Number of times debug spans were throttled.
  71. ThrottledDebugSpans metrics.Counter `metric:"throttled_debug_spans" help:"Number of times debug spans were throttled"`
  72. // Number of times throttler successfully updated.
  73. ThrottlerUpdateSuccess metrics.Counter `metric:"throttler_updates" tags:"result=ok" help:"Number of times throttler successfully updated"`
  74. // Number of times throttler failed to update.
  75. ThrottlerUpdateFailure metrics.Counter `metric:"throttler_updates" tags:"result=err" help:"Number of times throttler failed to update"`
  76. }
  77. // NewMetrics creates a new Metrics struct and initializes it.
  78. func NewMetrics(factory metrics.Factory, globalTags map[string]string) *Metrics {
  79. m := &Metrics{}
  80. // TODO the namespace "jaeger" should be configurable
  81. metrics.MustInit(m, factory.Namespace(metrics.NSOptions{Name: "jaeger"}).Namespace(metrics.NSOptions{Name: "tracer"}), globalTags)
  82. return m
  83. }
  84. // NewNullMetrics creates a new Metrics struct that won't report any metrics.
  85. func NewNullMetrics() *Metrics {
  86. return NewMetrics(metrics.NullFactory, nil)
  87. }