From 3d67ac86f53866332568b0f542265b00d86407fc Mon Sep 17 00:00:00 2001 From: Yuri Shkuro Date: Tue, 21 Jun 2022 11:59:01 -0400 Subject: [PATCH] Copy metrics API from jaeger-lib (#3767) * Copy metrics API from jaeger-lib Signed-off-by: Yuri Shkuro * fix builder Signed-off-by: Yuri Shkuro * move Signed-off-by: Yuri Shkuro * copy-fork Signed-off-by: Yuri Shkuro * upgrade-agent Signed-off-by: Yuri Shkuro * refactor-all Signed-off-by: Yuri Shkuro * fmt Signed-off-by: Yuri Shkuro * undo Signed-off-by: Yuri Shkuro * fix Signed-off-by: Yuri Shkuro * tests Signed-off-by: Yuri Shkuro --- cmd/agent/app/agent_test.go | 4 +- cmd/agent/app/builder.go | 2 +- cmd/agent/app/builder_test.go | 6 +- cmd/agent/app/configmanager/metrics.go | 3 +- cmd/agent/app/configmanager/metrics_test.go | 2 +- cmd/agent/app/httpserver/srv.go | 2 +- cmd/agent/app/processors/thrift_processor.go | 2 +- .../app/processors/thrift_processor_test.go | 4 +- cmd/agent/app/reporter/client_metrics.go | 2 +- cmd/agent/app/reporter/client_metrics_test.go | 2 +- cmd/agent/app/reporter/connect_metrics.go | 2 +- .../app/reporter/connect_metrics_test.go | 3 +- cmd/agent/app/reporter/grpc/builder.go | 2 +- cmd/agent/app/reporter/grpc/builder_test.go | 4 +- .../app/reporter/grpc/collector_proxy.go | 2 +- .../app/reporter/grpc/collector_proxy_test.go | 2 +- cmd/agent/app/reporter/metrics.go | 3 +- cmd/agent/app/reporter/metrics_test.go | 2 +- cmd/agent/app/servers/tbuffered_server.go | 2 +- .../app/servers/tbuffered_server_test.go | 2 +- cmd/agent/main.go | 6 +- cmd/all-in-one/main.go | 11 +- cmd/collector/app/collector.go | 2 +- cmd/collector/app/collector_test.go | 4 +- cmd/collector/app/metrics.go | 3 +- cmd/collector/app/metrics_test.go | 4 +- cmd/collector/app/options.go | 2 +- cmd/collector/app/options_test.go | 2 +- .../app/sampling/strategystore/factory.go | 2 +- cmd/collector/app/server/http.go | 2 +- cmd/collector/app/server/http_test.go | 2 +- cmd/collector/app/server/zipkin.go | 2 +- cmd/collector/app/server/zipkin_test.go | 2 +- cmd/collector/app/span_handler_builder.go | 2 +- .../app/span_handler_builder_test.go | 2 +- cmd/collector/app/span_processor_test.go | 4 +- cmd/collector/main.go | 6 +- cmd/flags/service.go | 15 +- cmd/flags/service_test.go | 14 + cmd/ingester/app/builder/builder.go | 2 +- cmd/ingester/app/consumer/consumer.go | 2 +- cmd/ingester/app/consumer/consumer_metrics.go | 2 +- cmd/ingester/app/consumer/consumer_test.go | 4 +- .../app/consumer/deadlock_detector.go | 3 +- .../app/consumer/deadlock_detector_test.go | 3 +- cmd/ingester/app/consumer/offset/manager.go | 2 +- .../app/consumer/offset/manager_test.go | 5 +- .../app/consumer/processor_factory.go | 2 +- .../app/consumer/processor_factory_test.go | 2 +- cmd/ingester/app/processor/decorator/retry.go | 3 +- .../app/processor/decorator/retry_test.go | 4 +- .../app/processor/metrics_decorator.go | 2 +- .../app/processor/metrics_decorator_test.go | 2 +- cmd/ingester/main.go | 2 +- cmd/query/app/mocks/Watcher.go | 1 - cmd/query/app/querysvc/query_service_test.go | 2 +- cmd/query/main.go | 4 +- internal/metrics/fork/fork.go | 67 +++ internal/metrics/fork/fork_test.go | 101 +++++ internal/metricstest/keys.go | 36 ++ internal/metricstest/local.go | 394 ++++++++++++++++++ internal/metricstest/local_test.go | 175 ++++++++ internal/metricstest/metricstest.go | 54 +++ internal/metricstest/metricstest_test.go | 29 ++ pkg/cassandra/metrics/table.go | 2 +- pkg/cassandra/metrics/table_test.go | 2 +- pkg/clientcfg/clientcfghttp/handler.go | 2 +- pkg/clientcfg/clientcfghttp/handler_test.go | 2 +- pkg/es/config/config.go | 2 +- pkg/es/mocks/Client.go | 1 - pkg/es/mocks/ClusterAPI.go | 1 - pkg/es/mocks/IndexAPI.go | 1 - pkg/es/mocks/IndexManagementLifecycleAPI.go | 1 - pkg/es/mocks/IndexService.go | 1 - pkg/es/mocks/IndicesCreateService.go | 1 - pkg/es/mocks/IndicesExistsService.go | 1 - pkg/es/mocks/MultiSearchService.go | 1 - pkg/es/mocks/SearchService.go | 1 - pkg/es/mocks/TemplateApplier.go | 1 - pkg/es/mocks/TemplateBuilder.go | 1 - pkg/es/mocks/TemplateCreateService.go | 1 - pkg/httpmetrics/metrics.go | 2 +- pkg/httpmetrics/metrics_test.go | 3 +- pkg/metrics/builder.go | 65 ++- pkg/metrics/builder_test.go | 12 +- pkg/metrics/counter.go | 29 ++ pkg/metrics/factory.go | 82 ++++ pkg/metrics/gauge.go | 29 ++ pkg/metrics/histogram.go | 28 ++ pkg/metrics/metrics.go | 138 ++++++ pkg/metrics/metrics_test.go | 144 +++++++ pkg/metrics/package.go | 3 +- pkg/metrics/stopwatch.go | 44 ++ pkg/metrics/timer.go | 34 ++ pkg/queue/bounded_queue.go | 3 +- pkg/queue/bounded_queue_test.go | 5 +- pkg/version/build.go | 2 +- .../strategystore/adaptive/aggregator.go | 2 +- .../strategystore/adaptive/aggregator_test.go | 2 +- .../strategystore/adaptive/factory.go | 2 +- .../strategystore/adaptive/factory_test.go | 2 +- .../strategystore/adaptive/processor.go | 2 +- .../strategystore/adaptive/processor_test.go | 4 +- .../strategystore/adaptive/strategy_store.go | 2 +- plugin/sampling/strategystore/factory.go | 2 +- plugin/sampling/strategystore/factory_test.go | 2 +- .../sampling/strategystore/static/factory.go | 2 +- .../strategystore/static/factory_test.go | 2 +- .../badger/dependencystore/storage_test.go | 2 +- plugin/storage/badger/factory.go | 2 +- plugin/storage/badger/factory_test.go | 4 +- .../badger/spanstore/read_write_test.go | 2 +- plugin/storage/badger/stats_linux_test.go | 2 +- plugin/storage/badger/stats_test.go | 2 +- .../cassandra/dependencystore/storage.go | 2 +- .../cassandra/dependencystore/storage_test.go | 4 +- plugin/storage/cassandra/factory.go | 2 +- plugin/storage/cassandra/factory_test.go | 2 +- .../cassandra/samplingstore/storage.go | 2 +- .../cassandra/samplingstore/storage_test.go | 2 +- .../storage/cassandra/savetracetest/main.go | 2 +- .../cassandra/spanstore/operation_names.go | 2 +- .../spanstore/operation_names_test.go | 2 +- plugin/storage/cassandra/spanstore/reader.go | 2 +- .../cassandra/spanstore/reader_test.go | 2 +- .../cassandra/spanstore/service_names.go | 2 +- .../cassandra/spanstore/service_names_test.go | 2 +- plugin/storage/cassandra/spanstore/writer.go | 2 +- .../cassandra/spanstore/writer_test.go | 2 +- plugin/storage/es/factory.go | 2 +- plugin/storage/es/factory_test.go | 2 +- plugin/storage/es/spanstore/reader.go | 2 +- plugin/storage/es/spanstore/reader_test.go | 2 +- plugin/storage/es/spanstore/writer.go | 2 +- plugin/storage/es/spanstore/writer_test.go | 2 +- plugin/storage/factory.go | 2 +- plugin/storage/factory_test.go | 6 +- plugin/storage/grpc/factory.go | 2 +- plugin/storage/grpc/factory_test.go | 2 +- .../storage/integration/badgerstore_test.go | 2 +- plugin/storage/integration/cassandra_test.go | 2 +- .../storage/integration/elasticsearch_test.go | 2 +- plugin/storage/integration/grpc_test.go | 2 +- plugin/storage/integration/kafka_test.go | 2 +- plugin/storage/kafka/factory.go | 2 +- plugin/storage/kafka/factory_test.go | 2 +- plugin/storage/kafka/writer.go | 2 +- plugin/storage/kafka/writer_test.go | 2 +- plugin/storage/memory/factory.go | 2 +- plugin/storage/memory/factory_test.go | 6 +- storage/factory.go | 2 +- storage/metricsstore/metrics/decorator.go | 3 +- .../metricsstore/metrics/decorator_test.go | 2 +- storage/metricsstore/mocks/Reader.go | 1 - storage/mocks/Factory.go | 2 +- storage/spanstore/downsampling_writer.go | 3 +- .../downsampling_writer_benchmark_test.go | 3 +- storage/spanstore/metrics/decorator.go | 3 +- storage/spanstore/metrics/decorator_test.go | 2 +- storage/spanstore/metrics/write_metrics.go | 2 +- .../spanstore/metrics/write_metrics_test.go | 3 +- storage/spanstore/mocks/Reader.go | 1 - storage/spanstore/mocks/Writer.go | 1 - 163 files changed, 1647 insertions(+), 189 deletions(-) create mode 100644 internal/metrics/fork/fork.go create mode 100644 internal/metrics/fork/fork_test.go create mode 100644 internal/metricstest/keys.go create mode 100644 internal/metricstest/local.go create mode 100644 internal/metricstest/local_test.go create mode 100644 internal/metricstest/metricstest.go create mode 100644 internal/metricstest/metricstest_test.go create mode 100644 pkg/metrics/counter.go create mode 100644 pkg/metrics/factory.go create mode 100644 pkg/metrics/gauge.go create mode 100644 pkg/metrics/histogram.go create mode 100644 pkg/metrics/metrics.go create mode 100644 pkg/metrics/metrics_test.go create mode 100644 pkg/metrics/stopwatch.go create mode 100644 pkg/metrics/timer.go diff --git a/cmd/agent/app/agent_test.go b/cmd/agent/app/agent_test.go index ee2ca6b234d..9f1b709ec0d 100644 --- a/cmd/agent/app/agent_test.go +++ b/cmd/agent/app/agent_test.go @@ -26,10 +26,10 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/uber/jaeger-lib/metrics" - "github.com/uber/jaeger-lib/metrics/fork" "go.uber.org/zap" + "github.com/jaegertracing/jaeger/internal/metrics/fork" + "github.com/jaegertracing/jaeger/pkg/metrics" jmetrics "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/pkg/testutils" ) diff --git a/cmd/agent/app/builder.go b/cmd/agent/app/builder.go index e9ee7831d03..e76961790ae 100644 --- a/cmd/agent/app/builder.go +++ b/cmd/agent/app/builder.go @@ -22,7 +22,6 @@ import ( "strconv" "github.com/apache/thrift/lib/go/thrift" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/cmd/agent/app/configmanager" @@ -31,6 +30,7 @@ import ( "github.com/jaegertracing/jaeger/cmd/agent/app/reporter" "github.com/jaegertracing/jaeger/cmd/agent/app/servers" "github.com/jaegertracing/jaeger/cmd/agent/app/servers/thriftudp" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/ports" agentThrift "github.com/jaegertracing/jaeger/thrift-gen/agent" ) diff --git a/cmd/agent/app/builder_test.go b/cmd/agent/app/builder_test.go index 661790437cb..e02577bab79 100644 --- a/cmd/agent/app/builder_test.go +++ b/cmd/agent/app/builder_test.go @@ -28,15 +28,15 @@ import ( "github.com/spf13/viper" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/uber/jaeger-lib/metrics" - "github.com/uber/jaeger-lib/metrics/fork" - "github.com/uber/jaeger-lib/metrics/metricstest" "go.uber.org/zap" yaml "gopkg.in/yaml.v2" "github.com/jaegertracing/jaeger/cmd/agent/app/configmanager" "github.com/jaegertracing/jaeger/cmd/agent/app/reporter" "github.com/jaegertracing/jaeger/cmd/agent/app/reporter/grpc" + "github.com/jaegertracing/jaeger/internal/metrics/fork" + "github.com/jaegertracing/jaeger/internal/metricstest" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/thrift-gen/baggage" "github.com/jaegertracing/jaeger/thrift-gen/jaeger" "github.com/jaegertracing/jaeger/thrift-gen/sampling" diff --git a/cmd/agent/app/configmanager/metrics.go b/cmd/agent/app/configmanager/metrics.go index 1046af9550b..1c46124d064 100644 --- a/cmd/agent/app/configmanager/metrics.go +++ b/cmd/agent/app/configmanager/metrics.go @@ -17,8 +17,7 @@ package configmanager import ( "context" - "github.com/uber/jaeger-lib/metrics" - + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/thrift-gen/baggage" "github.com/jaegertracing/jaeger/thrift-gen/sampling" ) diff --git a/cmd/agent/app/configmanager/metrics_test.go b/cmd/agent/app/configmanager/metrics_test.go index 2f179c223c6..df069166121 100644 --- a/cmd/agent/app/configmanager/metrics_test.go +++ b/cmd/agent/app/configmanager/metrics_test.go @@ -22,8 +22,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/uber/jaeger-lib/metrics/metricstest" + "github.com/jaegertracing/jaeger/internal/metricstest" "github.com/jaegertracing/jaeger/thrift-gen/baggage" "github.com/jaegertracing/jaeger/thrift-gen/sampling" ) diff --git a/cmd/agent/app/httpserver/srv.go b/cmd/agent/app/httpserver/srv.go index 227be0bb93b..7d4bbaaebcc 100644 --- a/cmd/agent/app/httpserver/srv.go +++ b/cmd/agent/app/httpserver/srv.go @@ -19,12 +19,12 @@ import ( "net/http" "github.com/gorilla/mux" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "go.uber.org/zap/zapcore" "github.com/jaegertracing/jaeger/cmd/agent/app/configmanager" "github.com/jaegertracing/jaeger/pkg/clientcfg/clientcfghttp" + "github.com/jaegertracing/jaeger/pkg/metrics" ) // NewHTTPServer creates a new server that hosts an HTTP/JSON endpoint for clients diff --git a/cmd/agent/app/processors/thrift_processor.go b/cmd/agent/app/processors/thrift_processor.go index ea4c8958be2..8856aa5a6b0 100644 --- a/cmd/agent/app/processors/thrift_processor.go +++ b/cmd/agent/app/processors/thrift_processor.go @@ -21,11 +21,11 @@ import ( "sync" "github.com/apache/thrift/lib/go/thrift" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/cmd/agent/app/customtransport" "github.com/jaegertracing/jaeger/cmd/agent/app/servers" + "github.com/jaegertracing/jaeger/pkg/metrics" ) // ThriftProcessor is a server that processes spans using a TBuffered Server diff --git a/cmd/agent/app/processors/thrift_processor_test.go b/cmd/agent/app/processors/thrift_processor_test.go index e12ed2ee81e..37a030b74cc 100644 --- a/cmd/agent/app/processors/thrift_processor_test.go +++ b/cmd/agent/app/processors/thrift_processor_test.go @@ -24,8 +24,6 @@ import ( "github.com/apache/thrift/lib/go/thrift" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/uber/jaeger-lib/metrics" - "github.com/uber/jaeger-lib/metrics/metricstest" "go.uber.org/zap" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" @@ -35,6 +33,8 @@ import ( "github.com/jaegertracing/jaeger/cmd/agent/app/servers" "github.com/jaegertracing/jaeger/cmd/agent/app/servers/thriftudp" "github.com/jaegertracing/jaeger/cmd/agent/app/testutils" + "github.com/jaegertracing/jaeger/internal/metricstest" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/thrift-gen/agent" "github.com/jaegertracing/jaeger/thrift-gen/jaeger" "github.com/jaegertracing/jaeger/thrift-gen/zipkincore" diff --git a/cmd/agent/app/reporter/client_metrics.go b/cmd/agent/app/reporter/client_metrics.go index efbaa8c6c96..1bfd8d82101 100644 --- a/cmd/agent/app/reporter/client_metrics.go +++ b/cmd/agent/app/reporter/client_metrics.go @@ -19,10 +19,10 @@ import ( "sync" "time" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/atomic" "go.uber.org/zap" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/thrift-gen/jaeger" "github.com/jaegertracing/jaeger/thrift-gen/zipkincore" ) diff --git a/cmd/agent/app/reporter/client_metrics_test.go b/cmd/agent/app/reporter/client_metrics_test.go index 83a7ed0307a..e943aa3383f 100644 --- a/cmd/agent/app/reporter/client_metrics_test.go +++ b/cmd/agent/app/reporter/client_metrics_test.go @@ -22,11 +22,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/uber/jaeger-lib/metrics/metricstest" "go.uber.org/zap" "go.uber.org/zap/zaptest/observer" "github.com/jaegertracing/jaeger/cmd/agent/app/testutils" + "github.com/jaegertracing/jaeger/internal/metricstest" "github.com/jaegertracing/jaeger/thrift-gen/jaeger" "github.com/jaegertracing/jaeger/thrift-gen/zipkincore" ) diff --git a/cmd/agent/app/reporter/connect_metrics.go b/cmd/agent/app/reporter/connect_metrics.go index 2c416ffbb6f..7af947eab1c 100644 --- a/cmd/agent/app/reporter/connect_metrics.go +++ b/cmd/agent/app/reporter/connect_metrics.go @@ -17,7 +17,7 @@ package reporter import ( "expvar" - "github.com/uber/jaeger-lib/metrics" + "github.com/jaegertracing/jaeger/pkg/metrics" ) type connectMetrics struct { diff --git a/cmd/agent/app/reporter/connect_metrics_test.go b/cmd/agent/app/reporter/connect_metrics_test.go index d5ff2007f21..524752c84c2 100644 --- a/cmd/agent/app/reporter/connect_metrics_test.go +++ b/cmd/agent/app/reporter/connect_metrics_test.go @@ -20,7 +20,8 @@ import ( "time" "github.com/stretchr/testify/assert" - "github.com/uber/jaeger-lib/metrics/metricstest" + + "github.com/jaegertracing/jaeger/internal/metricstest" ) func TestConnectMetrics(t *testing.T) { diff --git a/cmd/agent/app/reporter/grpc/builder.go b/cmd/agent/app/reporter/grpc/builder.go index dfc3f6f4c31..ccc2a071c22 100644 --- a/cmd/agent/app/reporter/grpc/builder.go +++ b/cmd/agent/app/reporter/grpc/builder.go @@ -21,7 +21,6 @@ import ( "strings" grpc_retry "github.com/grpc-ecosystem/go-grpc-middleware/retry" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "google.golang.org/grpc" "google.golang.org/grpc/connectivity" @@ -34,6 +33,7 @@ import ( "github.com/jaegertracing/jaeger/pkg/config/tlscfg" "github.com/jaegertracing/jaeger/pkg/discovery" "github.com/jaegertracing/jaeger/pkg/discovery/grpcresolver" + "github.com/jaegertracing/jaeger/pkg/metrics" ) // ConnBuilder Struct to hold configurations diff --git a/cmd/agent/app/reporter/grpc/builder_test.go b/cmd/agent/app/reporter/grpc/builder_test.go index 4df5c395ba4..0f792171149 100644 --- a/cmd/agent/app/reporter/grpc/builder_test.go +++ b/cmd/agent/app/reporter/grpc/builder_test.go @@ -22,16 +22,16 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/uber/jaeger-lib/metrics" - "github.com/uber/jaeger-lib/metrics/metricstest" "go.uber.org/zap" "google.golang.org/grpc" "google.golang.org/grpc/connectivity" "google.golang.org/grpc/credentials" yaml "gopkg.in/yaml.v2" + "github.com/jaegertracing/jaeger/internal/metricstest" "github.com/jaegertracing/jaeger/pkg/config/tlscfg" "github.com/jaegertracing/jaeger/pkg/discovery" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/proto-gen/api_v2" "github.com/jaegertracing/jaeger/thrift-gen/jaeger" ) diff --git a/cmd/agent/app/reporter/grpc/collector_proxy.go b/cmd/agent/app/reporter/grpc/collector_proxy.go index 2d9dc94783f..d9628102097 100644 --- a/cmd/agent/app/reporter/grpc/collector_proxy.go +++ b/cmd/agent/app/reporter/grpc/collector_proxy.go @@ -17,13 +17,13 @@ package grpc import ( "io" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "google.golang.org/grpc" "github.com/jaegertracing/jaeger/cmd/agent/app/configmanager" grpcManager "github.com/jaegertracing/jaeger/cmd/agent/app/configmanager/grpc" "github.com/jaegertracing/jaeger/cmd/agent/app/reporter" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/pkg/multicloser" ) diff --git a/cmd/agent/app/reporter/grpc/collector_proxy_test.go b/cmd/agent/app/reporter/grpc/collector_proxy_test.go index 2d7ce67811d..b44a941b4f0 100644 --- a/cmd/agent/app/reporter/grpc/collector_proxy_test.go +++ b/cmd/agent/app/reporter/grpc/collector_proxy_test.go @@ -23,10 +23,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/uber/jaeger-lib/metrics/metricstest" "go.uber.org/zap" "google.golang.org/grpc" + "github.com/jaegertracing/jaeger/internal/metricstest" "github.com/jaegertracing/jaeger/proto-gen/api_v2" "github.com/jaegertracing/jaeger/thrift-gen/jaeger" ) diff --git a/cmd/agent/app/reporter/metrics.go b/cmd/agent/app/reporter/metrics.go index 6b0f0225ebd..a1edaca36c2 100644 --- a/cmd/agent/app/reporter/metrics.go +++ b/cmd/agent/app/reporter/metrics.go @@ -17,8 +17,7 @@ package reporter import ( "context" - "github.com/uber/jaeger-lib/metrics" - + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/thrift-gen/jaeger" "github.com/jaegertracing/jaeger/thrift-gen/zipkincore" ) diff --git a/cmd/agent/app/reporter/metrics_test.go b/cmd/agent/app/reporter/metrics_test.go index d1281fd29ed..59e5d890662 100644 --- a/cmd/agent/app/reporter/metrics_test.go +++ b/cmd/agent/app/reporter/metrics_test.go @@ -21,8 +21,8 @@ import ( "time" "github.com/stretchr/testify/require" - "github.com/uber/jaeger-lib/metrics/metricstest" + "github.com/jaegertracing/jaeger/internal/metricstest" "github.com/jaegertracing/jaeger/thrift-gen/jaeger" "github.com/jaegertracing/jaeger/thrift-gen/zipkincore" ) diff --git a/cmd/agent/app/servers/tbuffered_server.go b/cmd/agent/app/servers/tbuffered_server.go index c4764cfea11..6a9d49b45ad 100644 --- a/cmd/agent/app/servers/tbuffered_server.go +++ b/cmd/agent/app/servers/tbuffered_server.go @@ -20,7 +20,7 @@ import ( "sync" "sync/atomic" - "github.com/uber/jaeger-lib/metrics" + "github.com/jaegertracing/jaeger/pkg/metrics" ) // ThriftTransport is a subset of thrift.TTransport methods, for easier mocking. diff --git a/cmd/agent/app/servers/tbuffered_server_test.go b/cmd/agent/app/servers/tbuffered_server_test.go index e1d5459ea1b..bf3df2d16ef 100644 --- a/cmd/agent/app/servers/tbuffered_server_test.go +++ b/cmd/agent/app/servers/tbuffered_server_test.go @@ -25,12 +25,12 @@ import ( "github.com/apache/thrift/lib/go/thrift" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/uber/jaeger-lib/metrics/metricstest" "go.uber.org/atomic" "github.com/jaegertracing/jaeger/cmd/agent/app/customtransport" "github.com/jaegertracing/jaeger/cmd/agent/app/servers/thriftudp" "github.com/jaegertracing/jaeger/cmd/agent/app/testutils" + "github.com/jaegertracing/jaeger/internal/metricstest" "github.com/jaegertracing/jaeger/thrift-gen/agent" "github.com/jaegertracing/jaeger/thrift-gen/zipkincore" ) diff --git a/cmd/agent/main.go b/cmd/agent/main.go index 5b22ab7363a..f88572ac22a 100644 --- a/cmd/agent/main.go +++ b/cmd/agent/main.go @@ -21,9 +21,7 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/uber/jaeger-lib/metrics" jexpvar "github.com/uber/jaeger-lib/metrics/expvar" - "github.com/uber/jaeger-lib/metrics/fork" _ "go.uber.org/automaxprocs" "go.uber.org/zap" @@ -33,7 +31,9 @@ import ( "github.com/jaegertracing/jaeger/cmd/docs" "github.com/jaegertracing/jaeger/cmd/flags" "github.com/jaegertracing/jaeger/cmd/status" + "github.com/jaegertracing/jaeger/internal/metrics/fork" "github.com/jaegertracing/jaeger/pkg/config" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/pkg/version" "github.com/jaegertracing/jaeger/ports" ) @@ -56,7 +56,7 @@ func main() { Namespace(metrics.NSOptions{Name: "jaeger"}). Namespace(metrics.NSOptions{Name: "agent"}) mFactory := fork.New("internal", - jexpvar.NewFactory(10), // backend for internal opts + metrics.NewJLibAdapter(jexpvar.NewFactory(10)), // backend for internal opts baseFactory) version.NewInfoMetrics(mFactory) diff --git a/cmd/all-in-one/main.go b/cmd/all-in-one/main.go index 216936f36db..32daf8d1683 100644 --- a/cmd/all-in-one/main.go +++ b/cmd/all-in-one/main.go @@ -26,9 +26,8 @@ import ( "github.com/spf13/viper" jaegerClientConfig "github.com/uber/jaeger-client-go/config" jaegerClientZapLog "github.com/uber/jaeger-client-go/log/zap" - "github.com/uber/jaeger-lib/metrics" + jlibmetrics "github.com/uber/jaeger-lib/metrics" jexpvar "github.com/uber/jaeger-lib/metrics/expvar" - "github.com/uber/jaeger-lib/metrics/fork" _ "go.uber.org/automaxprocs" "go.uber.org/zap" @@ -44,7 +43,9 @@ import ( queryApp "github.com/jaegertracing/jaeger/cmd/query/app" "github.com/jaegertracing/jaeger/cmd/query/app/querysvc" "github.com/jaegertracing/jaeger/cmd/status" + "github.com/jaegertracing/jaeger/internal/metrics/fork" "github.com/jaegertracing/jaeger/pkg/config" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/pkg/version" metricsPlugin "github.com/jaegertracing/jaeger/plugin/metrics" ss "github.com/jaegertracing/jaeger/plugin/sampling/strategystore" @@ -97,11 +98,11 @@ by default uses only in-memory database.`, logger := svc.Logger // shortcut rootMetricsFactory := svc.MetricsFactory // shortcut metricsFactory := fork.New("internal", - jexpvar.NewFactory(10), // backend for internal opts + metrics.NewJLibAdapter(jexpvar.NewFactory(10)), // backend for internal opts rootMetricsFactory.Namespace(metrics.NSOptions{Name: "jaeger"})) version.NewInfoMetrics(metricsFactory) - tracerCloser := initTracer(rootMetricsFactory, svc.Logger) + tracerCloser := initTracer(svc.JLibMetricsFactory, svc.Logger) storageFactory.InitFromViper(v, logger) if err := storageFactory.Initialize(metricsFactory, logger); err != nil { @@ -283,7 +284,7 @@ func startQuery( return server } -func initTracer(metricsFactory metrics.Factory, logger *zap.Logger) io.Closer { +func initTracer(metricsFactory jlibmetrics.Factory, logger *zap.Logger) io.Closer { traceCfg := &jaegerClientConfig.Configuration{ ServiceName: "jaeger-query", Sampler: &jaegerClientConfig.SamplerConfig{ diff --git a/cmd/collector/app/collector.go b/cmd/collector/app/collector.go index 64dd39634b6..a81213d49d5 100644 --- a/cmd/collector/app/collector.go +++ b/cmd/collector/app/collector.go @@ -21,7 +21,6 @@ import ( "net/http" "time" - "github.com/uber/jaeger-lib/metrics" "go.opentelemetry.io/collector/component" "go.uber.org/zap" "google.golang.org/grpc" @@ -32,6 +31,7 @@ import ( "github.com/jaegertracing/jaeger/cmd/collector/app/sampling/strategystore" "github.com/jaegertracing/jaeger/cmd/collector/app/server" "github.com/jaegertracing/jaeger/pkg/healthcheck" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/storage/spanstore" ) diff --git a/cmd/collector/app/collector_test.go b/cmd/collector/app/collector_test.go index 039e0fe115e..06dc2fe70cd 100644 --- a/cmd/collector/app/collector_test.go +++ b/cmd/collector/app/collector_test.go @@ -22,12 +22,12 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/uber/jaeger-lib/metrics/fork" - "github.com/uber/jaeger-lib/metrics/metricstest" "go.uber.org/zap" "github.com/jaegertracing/jaeger/cmd/collector/app/flags" "github.com/jaegertracing/jaeger/cmd/collector/app/processor" + "github.com/jaegertracing/jaeger/internal/metrics/fork" + "github.com/jaegertracing/jaeger/internal/metricstest" "github.com/jaegertracing/jaeger/model" "github.com/jaegertracing/jaeger/pkg/healthcheck" "github.com/jaegertracing/jaeger/thrift-gen/sampling" diff --git a/cmd/collector/app/metrics.go b/cmd/collector/app/metrics.go index 89d75355f47..c7b5d551a8d 100644 --- a/cmd/collector/app/metrics.go +++ b/cmd/collector/app/metrics.go @@ -19,10 +19,9 @@ import ( "strings" "sync" - "github.com/uber/jaeger-lib/metrics" - "github.com/jaegertracing/jaeger/cmd/collector/app/processor" "github.com/jaegertracing/jaeger/model" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/pkg/normalizer" ) diff --git a/cmd/collector/app/metrics_test.go b/cmd/collector/app/metrics_test.go index 786d233c24a..41852f4d506 100644 --- a/cmd/collector/app/metrics_test.go +++ b/cmd/collector/app/metrics_test.go @@ -20,11 +20,11 @@ import ( "time" "github.com/stretchr/testify/assert" - jaegerM "github.com/uber/jaeger-lib/metrics" - "github.com/uber/jaeger-lib/metrics/metricstest" "github.com/jaegertracing/jaeger/cmd/collector/app/processor" + "github.com/jaegertracing/jaeger/internal/metricstest" "github.com/jaegertracing/jaeger/model" + jaegerM "github.com/jaegertracing/jaeger/pkg/metrics" ) func TestProcessorMetrics(t *testing.T) { diff --git a/cmd/collector/app/options.go b/cmd/collector/app/options.go index 9847d8e7245..3be6c2b04eb 100644 --- a/cmd/collector/app/options.go +++ b/cmd/collector/app/options.go @@ -16,13 +16,13 @@ package app import ( - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/cmd/collector/app/flags" "github.com/jaegertracing/jaeger/cmd/collector/app/processor" "github.com/jaegertracing/jaeger/cmd/collector/app/sanitizer" "github.com/jaegertracing/jaeger/model" + "github.com/jaegertracing/jaeger/pkg/metrics" ) type options struct { diff --git a/cmd/collector/app/options_test.go b/cmd/collector/app/options_test.go index 6a92344b0fd..1d4ba298124 100644 --- a/cmd/collector/app/options_test.go +++ b/cmd/collector/app/options_test.go @@ -19,12 +19,12 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/cmd/collector/app/flags" "github.com/jaegertracing/jaeger/cmd/collector/app/processor" "github.com/jaegertracing/jaeger/model" + "github.com/jaegertracing/jaeger/pkg/metrics" ) func TestAllOptionSet(t *testing.T) { diff --git a/cmd/collector/app/sampling/strategystore/factory.go b/cmd/collector/app/sampling/strategystore/factory.go index bd9f33b724e..e47bd3105b0 100644 --- a/cmd/collector/app/sampling/strategystore/factory.go +++ b/cmd/collector/app/sampling/strategystore/factory.go @@ -15,9 +15,9 @@ package strategystore import ( - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/storage" ) diff --git a/cmd/collector/app/server/http.go b/cmd/collector/app/server/http.go index 09edb742b7e..ab5e67e17ed 100644 --- a/cmd/collector/app/server/http.go +++ b/cmd/collector/app/server/http.go @@ -19,7 +19,6 @@ import ( "net/http" "github.com/gorilla/mux" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "go.uber.org/zap/zapcore" @@ -29,6 +28,7 @@ import ( "github.com/jaegertracing/jaeger/pkg/config/tlscfg" "github.com/jaegertracing/jaeger/pkg/healthcheck" "github.com/jaegertracing/jaeger/pkg/httpmetrics" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/pkg/recoveryhandler" ) diff --git a/cmd/collector/app/server/http_test.go b/cmd/collector/app/server/http_test.go index 49d49c4877d..5e9b571d49c 100644 --- a/cmd/collector/app/server/http_test.go +++ b/cmd/collector/app/server/http_test.go @@ -25,10 +25,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/uber/jaeger-lib/metrics/metricstest" "go.uber.org/zap" "github.com/jaegertracing/jaeger/cmd/collector/app/handler" + "github.com/jaegertracing/jaeger/internal/metricstest" "github.com/jaegertracing/jaeger/pkg/config/tlscfg" "github.com/jaegertracing/jaeger/pkg/healthcheck" "github.com/jaegertracing/jaeger/ports" diff --git a/cmd/collector/app/server/zipkin.go b/cmd/collector/app/server/zipkin.go index 49432a76c65..c7f7fcefb3e 100644 --- a/cmd/collector/app/server/zipkin.go +++ b/cmd/collector/app/server/zipkin.go @@ -21,7 +21,6 @@ import ( "github.com/gorilla/mux" "github.com/rs/cors" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "go.uber.org/zap/zapcore" @@ -30,6 +29,7 @@ import ( "github.com/jaegertracing/jaeger/pkg/config/tlscfg" "github.com/jaegertracing/jaeger/pkg/healthcheck" "github.com/jaegertracing/jaeger/pkg/httpmetrics" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/pkg/recoveryhandler" ) diff --git a/cmd/collector/app/server/zipkin_test.go b/cmd/collector/app/server/zipkin_test.go index 7eb58c1e354..73289360cb7 100644 --- a/cmd/collector/app/server/zipkin_test.go +++ b/cmd/collector/app/server/zipkin_test.go @@ -25,10 +25,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/uber/jaeger-lib/metrics/metricstest" "go.uber.org/zap" "github.com/jaegertracing/jaeger/cmd/collector/app/handler" + "github.com/jaegertracing/jaeger/internal/metricstest" "github.com/jaegertracing/jaeger/pkg/config/tlscfg" "github.com/jaegertracing/jaeger/pkg/healthcheck" "github.com/jaegertracing/jaeger/ports" diff --git a/cmd/collector/app/span_handler_builder.go b/cmd/collector/app/span_handler_builder.go index 6ba46da3856..440aaaf6a6a 100644 --- a/cmd/collector/app/span_handler_builder.go +++ b/cmd/collector/app/span_handler_builder.go @@ -18,7 +18,6 @@ package app import ( "os" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/cmd/collector/app/flags" @@ -27,6 +26,7 @@ import ( zs "github.com/jaegertracing/jaeger/cmd/collector/app/sanitizer/zipkin" "github.com/jaegertracing/jaeger/model" "github.com/jaegertracing/jaeger/pkg/config/tenancy" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/storage/spanstore" ) diff --git a/cmd/collector/app/span_handler_builder_test.go b/cmd/collector/app/span_handler_builder_test.go index 0130165ac69..ec02e0e4503 100644 --- a/cmd/collector/app/span_handler_builder_test.go +++ b/cmd/collector/app/span_handler_builder_test.go @@ -20,12 +20,12 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/cmd/collector/app/flags" cmdFlags "github.com/jaegertracing/jaeger/cmd/flags" "github.com/jaegertracing/jaeger/pkg/config" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/plugin/storage/memory" ) diff --git a/cmd/collector/app/span_processor_test.go b/cmd/collector/app/span_processor_test.go index 874760a41cb..228b9868468 100644 --- a/cmd/collector/app/span_processor_test.go +++ b/cmd/collector/app/span_processor_test.go @@ -25,15 +25,15 @@ import ( "time" "github.com/stretchr/testify/assert" - "github.com/uber/jaeger-lib/metrics" - "github.com/uber/jaeger-lib/metrics/metricstest" "go.uber.org/atomic" "go.uber.org/zap" "github.com/jaegertracing/jaeger/cmd/collector/app/handler" "github.com/jaegertracing/jaeger/cmd/collector/app/processor" zipkinSanitizer "github.com/jaegertracing/jaeger/cmd/collector/app/sanitizer/zipkin" + "github.com/jaegertracing/jaeger/internal/metricstest" "github.com/jaegertracing/jaeger/model" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/pkg/testutils" "github.com/jaegertracing/jaeger/storage" "github.com/jaegertracing/jaeger/thrift-gen/jaeger" diff --git a/cmd/collector/main.go b/cmd/collector/main.go index 7cf7b025607..ce70a3f2119 100644 --- a/cmd/collector/main.go +++ b/cmd/collector/main.go @@ -23,9 +23,7 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/uber/jaeger-lib/metrics" jexpvar "github.com/uber/jaeger-lib/metrics/expvar" - "github.com/uber/jaeger-lib/metrics/fork" _ "go.uber.org/automaxprocs" "go.uber.org/zap" @@ -35,7 +33,9 @@ import ( "github.com/jaegertracing/jaeger/cmd/env" cmdFlags "github.com/jaegertracing/jaeger/cmd/flags" "github.com/jaegertracing/jaeger/cmd/status" + "github.com/jaegertracing/jaeger/internal/metrics/fork" "github.com/jaegertracing/jaeger/pkg/config" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/pkg/version" ss "github.com/jaegertracing/jaeger/plugin/sampling/strategystore" "github.com/jaegertracing/jaeger/plugin/storage" @@ -72,7 +72,7 @@ func main() { logger := svc.Logger // shortcut baseFactory := svc.MetricsFactory.Namespace(metrics.NSOptions{Name: "jaeger"}) metricsFactory := fork.New("internal", - jexpvar.NewFactory(10), // backend for internal opts + metrics.NewJLibAdapter(jexpvar.NewFactory(10)), // backend for internal opts baseFactory.Namespace(metrics.NSOptions{Name: "collector"})) version.NewInfoMetrics(metricsFactory) diff --git a/cmd/flags/service.go b/cmd/flags/service.go index f2ee9ba2ebb..d079adc099c 100644 --- a/cmd/flags/service.go +++ b/cmd/flags/service.go @@ -24,11 +24,11 @@ import ( grpcZap "github.com/grpc-ecosystem/go-grpc-middleware/logging/zap" "github.com/spf13/viper" - "github.com/uber/jaeger-lib/metrics" + jlibmetrics "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/pkg/healthcheck" - pMetrics "github.com/jaegertracing/jaeger/pkg/metrics" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/ports" ) @@ -49,6 +49,8 @@ type Service struct { // MetricsFactory is the root factory without a namespace. MetricsFactory metrics.Factory + JLibMetricsFactory jlibmetrics.Factory + signalsChannel chan os.Signal hcStatusChannel chan healthcheck.Status @@ -75,7 +77,7 @@ func (s *Service) AddFlags(flagSet *flag.FlagSet) { } else { AddFlags(flagSet) } - pMetrics.AddFlags(flagSet) + metrics.AddFlags(flagSet) s.Admin.AddFlags(flagSet) } @@ -104,12 +106,17 @@ func (s *Service) Start(v *viper.Viper) error { return fmt.Errorf("cannot create logger: %w", err) } - metricsBuilder := new(pMetrics.Builder).InitFromViper(v) + metricsBuilder := new(metrics.Builder).InitFromViper(v) metricsFactory, err := metricsBuilder.CreateMetricsFactory("") if err != nil { return fmt.Errorf("cannot create metrics factory: %w", err) } s.MetricsFactory = metricsFactory + if jlib, ok := metricsFactory.(*metrics.JLibAdapter); ok { + s.JLibMetricsFactory = jlib.Unwrap() + } else { + s.JLibMetricsFactory = jlibmetrics.NullFactory + } if err = s.Admin.initFromViper(v, s.Logger); err != nil { return fmt.Errorf("cannot initialize admin server: %w", err) diff --git a/cmd/flags/service_test.go b/cmd/flags/service_test.go index 7c7601f470b..df4959181f0 100644 --- a/cmd/flags/service_test.go +++ b/cmd/flags/service_test.go @@ -22,10 +22,12 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + jlibmetrics "github.com/uber/jaeger-lib/metrics" "go.uber.org/atomic" "github.com/jaegertracing/jaeger/pkg/config" "github.com/jaegertracing/jaeger/pkg/healthcheck" + "github.com/jaegertracing/jaeger/pkg/metrics" ) func TestAddFlags(t *testing.T) { @@ -112,3 +114,15 @@ func waitForEqual(t *testing.T, expected interface{}, getter func() interface{}) } assert.Equal(t, expected, getter()) } + +func TestNullMetricsFactory(t *testing.T) { + v, cmd := config.Viperize(metrics.AddFlags) + err := cmd.ParseFlags([]string{ + "--metrics-backend=none", + }) + require.NoError(t, err) + + s := NewService(0) + s.Start(v) + assert.IsType(t, jlibmetrics.NullFactory, s.JLibMetricsFactory) +} diff --git a/cmd/ingester/app/builder/builder.go b/cmd/ingester/app/builder/builder.go index d5cd0efc8ad..d984b5dcd03 100644 --- a/cmd/ingester/app/builder/builder.go +++ b/cmd/ingester/app/builder/builder.go @@ -18,13 +18,13 @@ import ( "fmt" "strings" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/cmd/ingester/app" "github.com/jaegertracing/jaeger/cmd/ingester/app/consumer" "github.com/jaegertracing/jaeger/cmd/ingester/app/processor" kafkaConsumer "github.com/jaegertracing/jaeger/pkg/kafka/consumer" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/plugin/storage/kafka" "github.com/jaegertracing/jaeger/storage/spanstore" ) diff --git a/cmd/ingester/app/consumer/consumer.go b/cmd/ingester/app/consumer/consumer.go index 856336239b4..ab0d8be8c2e 100644 --- a/cmd/ingester/app/consumer/consumer.go +++ b/cmd/ingester/app/consumer/consumer.go @@ -20,11 +20,11 @@ import ( "github.com/Shopify/sarama" sc "github.com/bsm/sarama-cluster" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/cmd/ingester/app/processor" "github.com/jaegertracing/jaeger/pkg/kafka/consumer" + "github.com/jaegertracing/jaeger/pkg/metrics" ) // Params are the parameters of a Consumer diff --git a/cmd/ingester/app/consumer/consumer_metrics.go b/cmd/ingester/app/consumer/consumer_metrics.go index 34b2c8e8ddc..c744c24eb77 100644 --- a/cmd/ingester/app/consumer/consumer_metrics.go +++ b/cmd/ingester/app/consumer/consumer_metrics.go @@ -17,7 +17,7 @@ package consumer import ( "strconv" - "github.com/uber/jaeger-lib/metrics" + "github.com/jaegertracing/jaeger/pkg/metrics" ) const consumerNamespace = "sarama-consumer" diff --git a/cmd/ingester/app/consumer/consumer_test.go b/cmd/ingester/app/consumer/consumer_test.go index 4454e7de75b..731218b4b19 100644 --- a/cmd/ingester/app/consumer/consumer_test.go +++ b/cmd/ingester/app/consumer/consumer_test.go @@ -27,14 +27,14 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - "github.com/uber/jaeger-lib/metrics" - "github.com/uber/jaeger-lib/metrics/metricstest" "go.uber.org/zap" kmocks "github.com/jaegertracing/jaeger/cmd/ingester/app/consumer/mocks" "github.com/jaegertracing/jaeger/cmd/ingester/app/processor" pmocks "github.com/jaegertracing/jaeger/cmd/ingester/app/processor/mocks" + "github.com/jaegertracing/jaeger/internal/metricstest" "github.com/jaegertracing/jaeger/pkg/kafka/consumer" + "github.com/jaegertracing/jaeger/pkg/metrics" ) //go:generate mockery -dir ../../../../pkg/kafka/config/ -name Consumer diff --git a/cmd/ingester/app/consumer/deadlock_detector.go b/cmd/ingester/app/consumer/deadlock_detector.go index 13e932abaa3..bac160f7d00 100644 --- a/cmd/ingester/app/consumer/deadlock_detector.go +++ b/cmd/ingester/app/consumer/deadlock_detector.go @@ -19,8 +19,9 @@ import ( "sync/atomic" "time" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" + + "github.com/jaegertracing/jaeger/pkg/metrics" ) // deadlockDetector monitors the messages consumed and wither signals for the partition to be closed by sending a diff --git a/cmd/ingester/app/consumer/deadlock_detector_test.go b/cmd/ingester/app/consumer/deadlock_detector_test.go index 482c29d0fda..6cef1c00b6c 100644 --- a/cmd/ingester/app/consumer/deadlock_detector_test.go +++ b/cmd/ingester/app/consumer/deadlock_detector_test.go @@ -21,8 +21,9 @@ import ( "time" "github.com/stretchr/testify/assert" - "github.com/uber/jaeger-lib/metrics/metricstest" "go.uber.org/zap" + + "github.com/jaegertracing/jaeger/internal/metricstest" ) func TestClosingSignalEmitted(t *testing.T) { diff --git a/cmd/ingester/app/consumer/offset/manager.go b/cmd/ingester/app/consumer/offset/manager.go index 63f46abaae8..a9e39be8910 100644 --- a/cmd/ingester/app/consumer/offset/manager.go +++ b/cmd/ingester/app/consumer/offset/manager.go @@ -19,7 +19,7 @@ import ( "sync" "time" - "github.com/uber/jaeger-lib/metrics" + "github.com/jaegertracing/jaeger/pkg/metrics" ) const ( diff --git a/cmd/ingester/app/consumer/offset/manager_test.go b/cmd/ingester/app/consumer/offset/manager_test.go index c29c8fd582d..58a0a2020e9 100644 --- a/cmd/ingester/app/consumer/offset/manager_test.go +++ b/cmd/ingester/app/consumer/offset/manager_test.go @@ -20,8 +20,9 @@ import ( "time" "github.com/stretchr/testify/assert" - "github.com/uber/jaeger-lib/metrics" - "github.com/uber/jaeger-lib/metrics/metricstest" + + "github.com/jaegertracing/jaeger/internal/metricstest" + "github.com/jaegertracing/jaeger/pkg/metrics" ) func TestHandleReset(t *testing.T) { diff --git a/cmd/ingester/app/consumer/processor_factory.go b/cmd/ingester/app/consumer/processor_factory.go index abec3daa800..3bef57b8f6c 100644 --- a/cmd/ingester/app/consumer/processor_factory.go +++ b/cmd/ingester/app/consumer/processor_factory.go @@ -17,13 +17,13 @@ package consumer import ( "io" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/cmd/ingester/app/consumer/offset" "github.com/jaegertracing/jaeger/cmd/ingester/app/processor" "github.com/jaegertracing/jaeger/cmd/ingester/app/processor/decorator" "github.com/jaegertracing/jaeger/pkg/kafka/consumer" + "github.com/jaegertracing/jaeger/pkg/metrics" ) // ProcessorFactoryParams are the parameters of a ProcessorFactory diff --git a/cmd/ingester/app/consumer/processor_factory_test.go b/cmd/ingester/app/consumer/processor_factory_test.go index 9cbd0ecfdf2..c2b47f9e0d3 100644 --- a/cmd/ingester/app/consumer/processor_factory_test.go +++ b/cmd/ingester/app/consumer/processor_factory_test.go @@ -20,11 +20,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" kmocks "github.com/jaegertracing/jaeger/cmd/ingester/app/consumer/mocks" "github.com/jaegertracing/jaeger/cmd/ingester/app/processor/mocks" + "github.com/jaegertracing/jaeger/pkg/metrics" ) func Test_NewFactory(t *testing.T) { diff --git a/cmd/ingester/app/processor/decorator/retry.go b/cmd/ingester/app/processor/decorator/retry.go index e5551792a8e..70733d0f741 100644 --- a/cmd/ingester/app/processor/decorator/retry.go +++ b/cmd/ingester/app/processor/decorator/retry.go @@ -19,9 +19,8 @@ import ( "math/rand" "time" - "github.com/uber/jaeger-lib/metrics" - "github.com/jaegertracing/jaeger/cmd/ingester/app/processor" + "github.com/jaegertracing/jaeger/pkg/metrics" ) type retryDecorator struct { diff --git a/cmd/ingester/app/processor/decorator/retry_test.go b/cmd/ingester/app/processor/decorator/retry_test.go index f59a0c8be4f..d2127b763a7 100644 --- a/cmd/ingester/app/processor/decorator/retry_test.go +++ b/cmd/ingester/app/processor/decorator/retry_test.go @@ -20,10 +20,10 @@ import ( "time" "github.com/stretchr/testify/assert" - "github.com/uber/jaeger-lib/metrics" - "github.com/uber/jaeger-lib/metrics/metricstest" "github.com/jaegertracing/jaeger/cmd/ingester/app/processor/mocks" + "github.com/jaegertracing/jaeger/internal/metricstest" + "github.com/jaegertracing/jaeger/pkg/metrics" ) type fakeMsg struct{} diff --git a/cmd/ingester/app/processor/metrics_decorator.go b/cmd/ingester/app/processor/metrics_decorator.go index 40d52003f37..2983d2f6400 100644 --- a/cmd/ingester/app/processor/metrics_decorator.go +++ b/cmd/ingester/app/processor/metrics_decorator.go @@ -18,7 +18,7 @@ import ( "io" "time" - "github.com/uber/jaeger-lib/metrics" + "github.com/jaegertracing/jaeger/pkg/metrics" ) type metricsDecorator struct { diff --git a/cmd/ingester/app/processor/metrics_decorator_test.go b/cmd/ingester/app/processor/metrics_decorator_test.go index d68d7941bd1..704269674e9 100644 --- a/cmd/ingester/app/processor/metrics_decorator_test.go +++ b/cmd/ingester/app/processor/metrics_decorator_test.go @@ -19,10 +19,10 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/uber/jaeger-lib/metrics/metricstest" "github.com/jaegertracing/jaeger/cmd/ingester/app/processor" "github.com/jaegertracing/jaeger/cmd/ingester/app/processor/mocks" + "github.com/jaegertracing/jaeger/internal/metricstest" ) type fakeMsg struct{} diff --git a/cmd/ingester/main.go b/cmd/ingester/main.go index 6a9364f0e5e..b8cce567937 100644 --- a/cmd/ingester/main.go +++ b/cmd/ingester/main.go @@ -22,7 +22,6 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/uber/jaeger-lib/metrics" _ "go.uber.org/automaxprocs" "go.uber.org/zap" @@ -33,6 +32,7 @@ import ( "github.com/jaegertracing/jaeger/cmd/ingester/app/builder" "github.com/jaegertracing/jaeger/cmd/status" "github.com/jaegertracing/jaeger/pkg/config" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/pkg/version" "github.com/jaegertracing/jaeger/plugin/storage" "github.com/jaegertracing/jaeger/ports" diff --git a/cmd/query/app/mocks/Watcher.go b/cmd/query/app/mocks/Watcher.go index 37b1c9b8736..1cd05b0defc 100644 --- a/cmd/query/app/mocks/Watcher.go +++ b/cmd/query/app/mocks/Watcher.go @@ -14,7 +14,6 @@ // See the License for the specific language governing permissions and // limitations under the License. - package mocks import ( diff --git a/cmd/query/app/querysvc/query_service_test.go b/cmd/query/app/querysvc/query_service_test.go index 21b9851d73b..79e66253be2 100644 --- a/cmd/query/app/querysvc/query_service_test.go +++ b/cmd/query/app/querysvc/query_service_test.go @@ -22,11 +22,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/model" "github.com/jaegertracing/jaeger/model/adjuster" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/storage" "github.com/jaegertracing/jaeger/storage/dependencystore" depsmocks "github.com/jaegertracing/jaeger/storage/dependencystore/mocks" diff --git a/cmd/query/main.go b/cmd/query/main.go index ea40dcf9790..30c6b178f7e 100644 --- a/cmd/query/main.go +++ b/cmd/query/main.go @@ -25,7 +25,6 @@ import ( "github.com/spf13/viper" jaegerClientConfig "github.com/uber/jaeger-client-go/config" jaegerClientZapLog "github.com/uber/jaeger-client-go/log/zap" - "github.com/uber/jaeger-lib/metrics" _ "go.uber.org/automaxprocs" "go.uber.org/zap" @@ -37,6 +36,7 @@ import ( "github.com/jaegertracing/jaeger/cmd/status" "github.com/jaegertracing/jaeger/pkg/bearertoken" "github.com/jaegertracing/jaeger/pkg/config" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/pkg/version" metricsPlugin "github.com/jaegertracing/jaeger/plugin/metrics" "github.com/jaegertracing/jaeger/plugin/storage" @@ -86,7 +86,7 @@ func main() { logger.Fatal("Failed to read tracer configuration", zap.Error(err)) } tracer, closer, err := traceCfg.NewTracer( - jaegerClientConfig.Metrics(svc.MetricsFactory), + jaegerClientConfig.Metrics(svc.JLibMetricsFactory), jaegerClientConfig.Logger(jaegerClientZapLog.NewLogger(logger)), ) if err != nil { diff --git a/internal/metrics/fork/fork.go b/internal/metrics/fork/fork.go new file mode 100644 index 00000000000..4940f47ef16 --- /dev/null +++ b/internal/metrics/fork/fork.go @@ -0,0 +1,67 @@ +// Copyright (c) 2020 The Jaeger Authors. +// +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// 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. + +package fork + +import "github.com/jaegertracing/jaeger/pkg/metrics" + +// Factory represents a metrics factory that delegates metrics with +// forkNamespace to forkFactory otherwise - defaultFactory is used. +type Factory struct { + forkNamespace string + forkFactory metrics.Factory + defaultFactory metrics.Factory +} + +// New creates new fork.Factory. +func New(forkNamespace string, forkFactory, defaultFactory metrics.Factory) metrics.Factory { + return &Factory{ + forkNamespace: forkNamespace, + forkFactory: forkFactory, + defaultFactory: defaultFactory, + } +} + +// Gauge implements metrics.Factory interface. +func (f *Factory) Gauge(options metrics.Options) metrics.Gauge { + return f.defaultFactory.Gauge(options) +} + +// Counter implements metrics.Factory interface. +func (f *Factory) Counter(metric metrics.Options) metrics.Counter { + return f.defaultFactory.Counter(metric) +} + +// Timer implements metrics.Factory interface. +func (f *Factory) Timer(metric metrics.TimerOptions) metrics.Timer { + return f.defaultFactory.Timer(metric) +} + +// Histogram implements metrics.Factory interface. +func (f *Factory) Histogram(metric metrics.HistogramOptions) metrics.Histogram { + return f.defaultFactory.Histogram(metric) +} + +// Namespace implements metrics.Factory interface. +func (f *Factory) Namespace(scope metrics.NSOptions) metrics.Factory { + if scope.Name == f.forkNamespace { + return f.forkFactory.Namespace(scope) + } + + return &Factory{ + forkNamespace: f.forkNamespace, + forkFactory: f.forkFactory.Namespace(scope), + defaultFactory: f.defaultFactory.Namespace(scope), + } +} diff --git a/internal/metrics/fork/fork_test.go b/internal/metrics/fork/fork_test.go new file mode 100644 index 00000000000..e1eb244bbcf --- /dev/null +++ b/internal/metrics/fork/fork_test.go @@ -0,0 +1,101 @@ +// Copyright (c) 2020 The Jaeger Authors. +// +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// 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. + +package fork + +import ( + "testing" + "time" + + "github.com/jaegertracing/jaeger/internal/metricstest" + "github.com/jaegertracing/jaeger/pkg/metrics" +) + +var _ metrics.Factory = (*Factory)(nil) + +func TestForkFactory(t *testing.T) { + forkNamespace := "internal" + forkFactory := metricstest.NewFactory(time.Second) + defaultFactory := metricstest.NewFactory(time.Second) + + // Create factory that will delegate namespaced metrics to forkFactory + // and add some metrics + ff := New(forkNamespace, forkFactory, defaultFactory) + ff.Gauge(metrics.Options{ + Name: "somegauge", + }).Update(42) + ff.Counter(metrics.Options{ + Name: "somecounter", + }).Inc(2) + + // Check that metrics are presented in defaultFactory backend + defaultFactory.AssertCounterMetrics(t, metricstest.ExpectedMetric{ + Name: "somecounter", + Value: 2, + }) + defaultFactory.AssertGaugeMetrics(t, metricstest.ExpectedMetric{ + Name: "somegauge", + Value: 42, + }) + + // Get default namespaced factory + defaultNamespacedFactory := ff.Namespace(metrics.NSOptions{ + Name: "default", + }) + + // Add some metrics + defaultNamespacedFactory.Counter(metrics.Options{ + Name: "somenamespacedcounter", + }).Inc(111) + defaultNamespacedFactory.Gauge(metrics.Options{ + Name: "somenamespacedgauge", + }).Update(222) + defaultNamespacedFactory.Histogram(metrics.HistogramOptions{ + Name: "somenamespacedhist", + }).Record(1) + defaultNamespacedFactory.Timer(metrics.TimerOptions{ + Name: "somenamespacedtimer", + }).Record(time.Millisecond) + + // Check values in default namespaced factory backend + defaultFactory.AssertCounterMetrics(t, metricstest.ExpectedMetric{ + Name: "default.somenamespacedcounter", + Value: 111, + }) + defaultFactory.AssertGaugeMetrics(t, metricstest.ExpectedMetric{ + Name: "default.somenamespacedgauge", + Value: 222, + }) + + // Get factory with forkNamespace and add some metrics + internalFactory := ff.Namespace(metrics.NSOptions{ + Name: forkNamespace, + }) + internalFactory.Gauge(metrics.Options{ + Name: "someinternalgauge", + }).Update(20) + internalFactory.Counter(metrics.Options{ + Name: "someinternalcounter", + }).Inc(50) + + // Check that metrics are presented in forkFactory backend + forkFactory.AssertGaugeMetrics(t, metricstest.ExpectedMetric{ + Name: "internal.someinternalgauge", + Value: 20, + }) + forkFactory.AssertCounterMetrics(t, metricstest.ExpectedMetric{ + Name: "internal.someinternalcounter", + Value: 50, + }) +} diff --git a/internal/metricstest/keys.go b/internal/metricstest/keys.go new file mode 100644 index 00000000000..7b7a2dfb5ef --- /dev/null +++ b/internal/metricstest/keys.go @@ -0,0 +1,36 @@ +// Copyright (c) 2022 The Jaeger Authors. +// Copyright (c) 2017 Uber Technologies, Inc. +// +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// 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. + +package metricstest + +import ( + "sort" +) + +// GetKey converts name+tags into a single string of the form +// "name|tag1=value1|...|tagN=valueN", where tag names are +// sorted alphabetically. +func GetKey(name string, tags map[string]string, tagsSep string, tagKVSep string) string { + keys := make([]string, 0, len(tags)) + for k := range tags { + keys = append(keys, k) + } + sort.Strings(keys) + key := name + for _, k := range keys { + key = key + tagsSep + k + tagKVSep + tags[k] + } + return key +} diff --git a/internal/metricstest/local.go b/internal/metricstest/local.go new file mode 100644 index 00000000000..4978a6d45b9 --- /dev/null +++ b/internal/metricstest/local.go @@ -0,0 +1,394 @@ +// Copyright (c) 2022 The Jaeger Authors. +// Copyright (c) 2017 Uber Technologies, Inc. +// +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// 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. + +package metricstest + +import ( + "sync" + "sync/atomic" + "time" + + "github.com/HdrHistogram/hdrhistogram-go" + + "github.com/jaegertracing/jaeger/pkg/metrics" +) + +// This is intentionally very similar to github.com/codahale/metrics, the +// main difference being that counters/gauges are scoped to the provider +// rather than being global (to facilitate testing). + +// A Backend is a metrics provider which aggregates data in-vm, and +// allows exporting snapshots to shove the data into a remote collector +type Backend struct { + cm sync.Mutex + gm sync.Mutex + tm sync.Mutex + hm sync.Mutex + counters map[string]*int64 + gauges map[string]*int64 + timers map[string]*localBackendTimer + histograms map[string]*localBackendHistogram + stop chan struct{} + wg sync.WaitGroup + TagsSep string + TagKVSep string +} + +// NewBackend returns a new Backend. The collectionInterval is the histogram +// time window for each timer. +func NewBackend(collectionInterval time.Duration) *Backend { + b := &Backend{ + counters: make(map[string]*int64), + gauges: make(map[string]*int64), + timers: make(map[string]*localBackendTimer), + histograms: make(map[string]*localBackendHistogram), + stop: make(chan struct{}), + TagsSep: "|", + TagKVSep: "=", + } + if collectionInterval == 0 { + // Use one histogram time window for all timers + return b + } + b.wg.Add(1) + go b.runLoop(collectionInterval) + return b +} + +// Clear discards accumulated stats +func (b *Backend) Clear() { + b.cm.Lock() + defer b.cm.Unlock() + b.gm.Lock() + defer b.gm.Unlock() + b.tm.Lock() + defer b.tm.Unlock() + b.hm.Lock() + defer b.hm.Unlock() + b.counters = make(map[string]*int64) + b.gauges = make(map[string]*int64) + b.timers = make(map[string]*localBackendTimer) + b.histograms = make(map[string]*localBackendHistogram) +} + +func (b *Backend) runLoop(collectionInterval time.Duration) { + defer b.wg.Done() + ticker := time.NewTicker(collectionInterval) + for { + select { + case <-ticker.C: + b.tm.Lock() + timers := make(map[string]*localBackendTimer, len(b.timers)) + for timerName, timer := range b.timers { + timers[timerName] = timer + } + b.tm.Unlock() + + for _, t := range timers { + t.Lock() + t.hist.Rotate() + t.Unlock() + } + case <-b.stop: + ticker.Stop() + return + } + } +} + +// IncCounter increments a counter value +func (b *Backend) IncCounter(name string, tags map[string]string, delta int64) { + name = GetKey(name, tags, b.TagsSep, b.TagKVSep) + b.cm.Lock() + defer b.cm.Unlock() + counter := b.counters[name] + if counter == nil { + b.counters[name] = new(int64) + *b.counters[name] = delta + return + } + atomic.AddInt64(counter, delta) +} + +// UpdateGauge updates the value of a gauge +func (b *Backend) UpdateGauge(name string, tags map[string]string, value int64) { + name = GetKey(name, tags, b.TagsSep, b.TagKVSep) + b.gm.Lock() + defer b.gm.Unlock() + gauge := b.gauges[name] + if gauge == nil { + b.gauges[name] = new(int64) + *b.gauges[name] = value + return + } + atomic.StoreInt64(gauge, value) +} + +// RecordHistogram records a timing duration +func (b *Backend) RecordHistogram(name string, tags map[string]string, v float64) { + name = GetKey(name, tags, b.TagsSep, b.TagKVSep) + histogram := b.findOrCreateHistogram(name) + histogram.Lock() + histogram.hist.Current.RecordValue(int64(v)) + histogram.Unlock() +} + +func (b *Backend) findOrCreateHistogram(name string) *localBackendHistogram { + b.hm.Lock() + defer b.hm.Unlock() + if t, ok := b.histograms[name]; ok { + return t + } + + t := &localBackendHistogram{ + hist: hdrhistogram.NewWindowed(5, 0, int64((5*time.Minute)/time.Millisecond), 1), + } + b.histograms[name] = t + return t +} + +type localBackendHistogram struct { + sync.Mutex + hist *hdrhistogram.WindowedHistogram +} + +// RecordTimer records a timing duration +func (b *Backend) RecordTimer(name string, tags map[string]string, d time.Duration) { + name = GetKey(name, tags, b.TagsSep, b.TagKVSep) + timer := b.findOrCreateTimer(name) + timer.Lock() + timer.hist.Current.RecordValue(int64(d / time.Millisecond)) + timer.Unlock() +} + +func (b *Backend) findOrCreateTimer(name string) *localBackendTimer { + b.tm.Lock() + defer b.tm.Unlock() + if t, ok := b.timers[name]; ok { + return t + } + + t := &localBackendTimer{ + hist: hdrhistogram.NewWindowed(5, 0, int64((5*time.Minute)/time.Millisecond), 1), + } + b.timers[name] = t + return t +} + +type localBackendTimer struct { + sync.Mutex + hist *hdrhistogram.WindowedHistogram +} + +var percentiles = map[string]float64{ + "P50": 50, + "P75": 75, + "P90": 90, + "P95": 95, + "P99": 99, + "P999": 99.9, +} + +// Snapshot captures a snapshot of the current counter and gauge values +func (b *Backend) Snapshot() (counters, gauges map[string]int64) { + b.cm.Lock() + defer b.cm.Unlock() + + counters = make(map[string]int64, len(b.counters)) + for name, value := range b.counters { + counters[name] = atomic.LoadInt64(value) + } + + b.gm.Lock() + defer b.gm.Unlock() + + gauges = make(map[string]int64, len(b.gauges)) + for name, value := range b.gauges { + gauges[name] = atomic.LoadInt64(value) + } + + b.tm.Lock() + timers := make(map[string]*localBackendTimer) + for timerName, timer := range b.timers { + timers[timerName] = timer + } + b.tm.Unlock() + + for timerName, timer := range timers { + timer.Lock() + hist := timer.hist.Merge() + timer.Unlock() + for name, q := range percentiles { + gauges[timerName+"."+name] = hist.ValueAtQuantile(q) + } + } + + b.hm.Lock() + histograms := make(map[string]*localBackendHistogram) + for histogramName, histogram := range b.histograms { + histograms[histogramName] = histogram + } + b.hm.Unlock() + + for histogramName, histogram := range histograms { + histogram.Lock() + hist := histogram.hist.Merge() + histogram.Unlock() + for name, q := range percentiles { + gauges[histogramName+"."+name] = hist.ValueAtQuantile(q) + } + } + + return +} + +// Stop cleanly closes the background goroutine spawned by NewBackend. +func (b *Backend) Stop() { + close(b.stop) + b.wg.Wait() +} + +type stats struct { + name string + tags map[string]string + buckets []float64 + durationBuckets []time.Duration + localBackend *Backend +} + +type localTimer struct { + stats +} + +func (l *localTimer) Record(d time.Duration) { + l.localBackend.RecordTimer(l.name, l.tags, d) +} + +type localHistogram struct { + stats +} + +func (l *localHistogram) Record(v float64) { + l.localBackend.RecordHistogram(l.name, l.tags, v) +} + +type localCounter struct { + stats +} + +func (l *localCounter) Inc(delta int64) { + l.localBackend.IncCounter(l.name, l.tags, delta) +} + +type localGauge struct { + stats +} + +func (l *localGauge) Update(value int64) { + l.localBackend.UpdateGauge(l.name, l.tags, value) +} + +// Factory stats factory that creates metrics that are stored locally +type Factory struct { + *Backend + namespace string + tags map[string]string +} + +// NewFactory returns a new LocalMetricsFactory +func NewFactory(collectionInterval time.Duration) *Factory { + return &Factory{ + Backend: NewBackend(collectionInterval), + } +} + +// appendTags adds the tags to the namespace tags and returns a combined map. +func (l *Factory) appendTags(tags map[string]string) map[string]string { + newTags := make(map[string]string) + for k, v := range l.tags { + newTags[k] = v + } + for k, v := range tags { + newTags[k] = v + } + return newTags +} + +func (l *Factory) newNamespace(name string) string { + if l.namespace == "" { + return name + } + + if name == "" { + return l.namespace + } + + return l.namespace + "." + name +} + +// Counter returns a local stats counter +func (l *Factory) Counter(options metrics.Options) metrics.Counter { + return &localCounter{ + stats{ + name: l.newNamespace(options.Name), + tags: l.appendTags(options.Tags), + localBackend: l.Backend, + }, + } +} + +// Timer returns a local stats timer. +func (l *Factory) Timer(options metrics.TimerOptions) metrics.Timer { + return &localTimer{ + stats{ + name: l.newNamespace(options.Name), + tags: l.appendTags(options.Tags), + durationBuckets: options.Buckets, + localBackend: l.Backend, + }, + } +} + +// Gauge returns a local stats gauge. +func (l *Factory) Gauge(options metrics.Options) metrics.Gauge { + return &localGauge{ + stats{ + name: l.newNamespace(options.Name), + tags: l.appendTags(options.Tags), + localBackend: l.Backend, + }, + } +} + +// Histogram returns a local stats histogram. +func (l *Factory) Histogram(options metrics.HistogramOptions) metrics.Histogram { + return &localHistogram{ + stats{ + name: l.newNamespace(options.Name), + tags: l.appendTags(options.Tags), + buckets: options.Buckets, + localBackend: l.Backend, + }, + } +} + +// Namespace returns a new namespace. +func (l *Factory) Namespace(scope metrics.NSOptions) metrics.Factory { + return &Factory{ + namespace: l.newNamespace(scope.Name), + tags: l.appendTags(scope.Tags), + Backend: l.Backend, + } +} diff --git a/internal/metricstest/local_test.go b/internal/metricstest/local_test.go new file mode 100644 index 00000000000..a99721dcc92 --- /dev/null +++ b/internal/metricstest/local_test.go @@ -0,0 +1,175 @@ +// Copyright (c) 2022 The Jaeger Authors. +// +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// 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. + +package metricstest + +import ( + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/jaegertracing/jaeger/pkg/metrics" +) + +func TestLocalMetrics(t *testing.T) { + tags := map[string]string{ + "x": "y", + } + + f := NewFactory(0) + defer f.Stop() + f.Counter(metrics.Options{ + Name: "my-counter", + Tags: tags, + }).Inc(4) + f.Counter(metrics.Options{ + Name: "my-counter", + Tags: tags, + }).Inc(6) + f.Counter(metrics.Options{ + Name: "my-counter", + }).Inc(6) + f.Counter(metrics.Options{ + Name: "other-counter", + }).Inc(8) + f.Gauge(metrics.Options{ + Name: "my-gauge", + }).Update(25) + f.Gauge(metrics.Options{ + Name: "my-gauge", + }).Update(43) + f.Gauge(metrics.Options{ + Name: "other-gauge", + }).Update(74) + f.Namespace(metrics.NSOptions{ + Name: "namespace", + Tags: tags, + }).Counter(metrics.Options{ + Name: "my-counter", + }).Inc(7) + f.Namespace(metrics.NSOptions{ + Name: "ns.subns", + }).Counter(metrics.Options{ + Tags: map[string]string{"service": "a-service"}, + }).Inc(9) + + timings := map[string][]time.Duration{ + "foo-latency": { + time.Second * 35, + time.Second * 6, + time.Millisecond * 576, + time.Second * 12, + }, + "bar-latency": { + time.Minute*4 + time.Second*34, + time.Minute*7 + time.Second*12, + time.Second * 625, + time.Second * 12, + }, + } + + for metric, timing := range timings { + for _, d := range timing { + f.Timer(metrics.TimerOptions{ + Name: metric, + }).Record(d) + } + } + + histogram := f.Histogram(metrics.HistogramOptions{ + Name: "my-histo", + }) + histogram.Record(321) + histogram.Record(42) + + c, g := f.Snapshot() + require.NotNil(t, c) + require.NotNil(t, g) + + assert.Equal(t, map[string]int64{ + "my-counter|x=y": 10, + "my-counter": 6, + "other-counter": 8, + "namespace.my-counter|x=y": 7, + "ns.subns|service=a-service": 9, + }, c) + + assert.Equal(t, map[string]int64{ + "bar-latency.P50": 278527, + "bar-latency.P75": 278527, + "bar-latency.P90": 442367, + "bar-latency.P95": 442367, + "bar-latency.P99": 442367, + "bar-latency.P999": 442367, + "foo-latency.P50": 6143, + "foo-latency.P75": 12287, + "foo-latency.P90": 36863, + "foo-latency.P95": 36863, + "foo-latency.P99": 36863, + "foo-latency.P999": 36863, + "my-gauge": 43, + "my-histo.P50": 43, + "my-histo.P75": 335, + "my-histo.P90": 335, + "my-histo.P95": 335, + "my-histo.P99": 335, + "my-histo.P999": 335, + "other-gauge": 74, + }, g) + + f.Clear() + c, g = f.Snapshot() + require.Empty(t, c) + require.Empty(t, g) +} + +func TestLocalMetricsInterval(t *testing.T) { + refreshInterval := time.Millisecond + const relativeCheckFrequency = 5 // check 5 times per refreshInterval + const maxChecks = 2 * relativeCheckFrequency + checkInterval := (refreshInterval * relativeCheckFrequency) / maxChecks + + f := NewFactory(refreshInterval) + defer f.Stop() + + f.Timer(metrics.TimerOptions{ + Name: "timer", + }).Record(1) + + f.tm.Lock() + timer := f.timers["timer"] + f.tm.Unlock() + assert.NotNil(t, timer) + + // timer.hist.Current is modified on every Rotate(), which is called by Backend after every refreshInterval + getCurr := func() interface{} { + timer.Lock() + defer timer.Unlock() + return timer.hist.Current + } + + curr := getCurr() + + // wait for twice as long as the refresh interval + for i := 0; i < maxChecks; i++ { + time.Sleep(checkInterval) + + if getCurr() != curr { + return + } + } + t.Fail() +} diff --git a/internal/metricstest/metricstest.go b/internal/metricstest/metricstest.go new file mode 100644 index 00000000000..954dd44ba45 --- /dev/null +++ b/internal/metricstest/metricstest.go @@ -0,0 +1,54 @@ +// Copyright (c) 2022 The Jaeger Authors. +// Copyright (c) 2017 Uber Technologies, Inc. +// +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// 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. + +package metricstest + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// ExpectedMetric contains metrics under test. +type ExpectedMetric struct { + Name string + Tags map[string]string + Value int +} + +// TODO do something similar for Timers + +// AssertCounterMetrics checks if counter metrics exist. +func (f *Factory) AssertCounterMetrics(t *testing.T, expectedMetrics ...ExpectedMetric) { + counters, _ := f.Snapshot() + assertMetrics(t, counters, expectedMetrics...) +} + +// AssertGaugeMetrics checks if gauge metrics exist. +func (f *Factory) AssertGaugeMetrics(t *testing.T, expectedMetrics ...ExpectedMetric) { + _, gauges := f.Snapshot() + assertMetrics(t, gauges, expectedMetrics...) +} + +func assertMetrics(t *testing.T, actualMetrics map[string]int64, expectedMetrics ...ExpectedMetric) { + for _, expected := range expectedMetrics { + key := GetKey(expected.Name, expected.Tags, "|", "=") + assert.EqualValues(t, + expected.Value, + actualMetrics[key], + "expected metric name: %s, tags: %+v", expected.Name, expected.Tags, + ) + } +} diff --git a/internal/metricstest/metricstest_test.go b/internal/metricstest/metricstest_test.go new file mode 100644 index 00000000000..c2654a5ee43 --- /dev/null +++ b/internal/metricstest/metricstest_test.go @@ -0,0 +1,29 @@ +// Copyright (c) 2022 The Jaeger Authors. +// +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// 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. + +package metricstest + +import ( + "testing" +) + +func TestAssertMetrics(t *testing.T) { + f := NewFactory(0) + tags := map[string]string{"key": "value"} + f.IncCounter("counter", tags, 1) + f.UpdateGauge("gauge", tags, 11) + + f.AssertCounterMetrics(t, ExpectedMetric{Name: "counter", Tags: tags, Value: 1}) + f.AssertGaugeMetrics(t, ExpectedMetric{Name: "gauge", Tags: tags, Value: 11}) +} diff --git a/pkg/cassandra/metrics/table.go b/pkg/cassandra/metrics/table.go index c1e2e7ab6ca..6df40c0c09e 100644 --- a/pkg/cassandra/metrics/table.go +++ b/pkg/cassandra/metrics/table.go @@ -19,10 +19,10 @@ import ( "fmt" "time" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/pkg/cassandra" + "github.com/jaegertracing/jaeger/pkg/metrics" storageMetrics "github.com/jaegertracing/jaeger/storage/spanstore/metrics" ) diff --git a/pkg/cassandra/metrics/table_test.go b/pkg/cassandra/metrics/table_test.go index 70a82fb3fc0..a41a92d6be1 100644 --- a/pkg/cassandra/metrics/table_test.go +++ b/pkg/cassandra/metrics/table_test.go @@ -21,8 +21,8 @@ import ( "time" "github.com/stretchr/testify/assert" - "github.com/uber/jaeger-lib/metrics/metricstest" + "github.com/jaegertracing/jaeger/internal/metricstest" "github.com/jaegertracing/jaeger/pkg/testutils" ) diff --git a/pkg/clientcfg/clientcfghttp/handler.go b/pkg/clientcfg/clientcfghttp/handler.go index af2ebe1a5c2..53b8e52fe15 100644 --- a/pkg/clientcfg/clientcfghttp/handler.go +++ b/pkg/clientcfg/clientcfghttp/handler.go @@ -23,9 +23,9 @@ import ( "strings" "github.com/gorilla/mux" - "github.com/uber/jaeger-lib/metrics" "github.com/jaegertracing/jaeger/cmd/agent/app/configmanager" + "github.com/jaegertracing/jaeger/pkg/metrics" tSampling "github.com/jaegertracing/jaeger/thrift-gen/sampling" ) diff --git a/pkg/clientcfg/clientcfghttp/handler_test.go b/pkg/clientcfg/clientcfghttp/handler_test.go index 4eb60701ff8..a12aadd8387 100644 --- a/pkg/clientcfg/clientcfghttp/handler_test.go +++ b/pkg/clientcfg/clientcfghttp/handler_test.go @@ -27,8 +27,8 @@ import ( "github.com/gorilla/mux" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/uber/jaeger-lib/metrics/metricstest" + "github.com/jaegertracing/jaeger/internal/metricstest" tSampling092 "github.com/jaegertracing/jaeger/pkg/clientcfg/clientcfghttp/thrift-0.9.2" "github.com/jaegertracing/jaeger/thrift-gen/baggage" "github.com/jaegertracing/jaeger/thrift-gen/sampling" diff --git a/pkg/es/config/config.go b/pkg/es/config/config.go index df6bfaa56ca..e6f7909d3e3 100644 --- a/pkg/es/config/config.go +++ b/pkg/es/config/config.go @@ -30,7 +30,6 @@ import ( "time" "github.com/olivere/elastic" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "go.uber.org/zap/zapcore" "go.uber.org/zap/zapgrpc" @@ -39,6 +38,7 @@ import ( "github.com/jaegertracing/jaeger/pkg/config/tlscfg" "github.com/jaegertracing/jaeger/pkg/es" eswrapper "github.com/jaegertracing/jaeger/pkg/es/wrapper" + "github.com/jaegertracing/jaeger/pkg/metrics" storageMetrics "github.com/jaegertracing/jaeger/storage/spanstore/metrics" ) diff --git a/pkg/es/mocks/Client.go b/pkg/es/mocks/Client.go index 75c8a1c47d3..9ea6a6683f0 100644 --- a/pkg/es/mocks/Client.go +++ b/pkg/es/mocks/Client.go @@ -14,7 +14,6 @@ // See the License for the specific language governing permissions and // limitations under the License. - package mocks import ( diff --git a/pkg/es/mocks/ClusterAPI.go b/pkg/es/mocks/ClusterAPI.go index c3686bc4a30..9efe8d9280e 100644 --- a/pkg/es/mocks/ClusterAPI.go +++ b/pkg/es/mocks/ClusterAPI.go @@ -14,7 +14,6 @@ // See the License for the specific language governing permissions and // limitations under the License. - package mocks import mock "github.com/stretchr/testify/mock" diff --git a/pkg/es/mocks/IndexAPI.go b/pkg/es/mocks/IndexAPI.go index f0a09c491d7..199bc07de91 100644 --- a/pkg/es/mocks/IndexAPI.go +++ b/pkg/es/mocks/IndexAPI.go @@ -14,7 +14,6 @@ // See the License for the specific language governing permissions and // limitations under the License. - package mocks import ( diff --git a/pkg/es/mocks/IndexManagementLifecycleAPI.go b/pkg/es/mocks/IndexManagementLifecycleAPI.go index 378c4cac6cd..9823d56f9d9 100644 --- a/pkg/es/mocks/IndexManagementLifecycleAPI.go +++ b/pkg/es/mocks/IndexManagementLifecycleAPI.go @@ -14,7 +14,6 @@ // See the License for the specific language governing permissions and // limitations under the License. - package mocks import mock "github.com/stretchr/testify/mock" diff --git a/pkg/es/mocks/IndexService.go b/pkg/es/mocks/IndexService.go index 5ecd4e69518..d9672d55cd6 100644 --- a/pkg/es/mocks/IndexService.go +++ b/pkg/es/mocks/IndexService.go @@ -14,7 +14,6 @@ // See the License for the specific language governing permissions and // limitations under the License. - package mocks import ( diff --git a/pkg/es/mocks/IndicesCreateService.go b/pkg/es/mocks/IndicesCreateService.go index 5971db09297..4f379a08496 100644 --- a/pkg/es/mocks/IndicesCreateService.go +++ b/pkg/es/mocks/IndicesCreateService.go @@ -14,7 +14,6 @@ // See the License for the specific language governing permissions and // limitations under the License. - package mocks import ( diff --git a/pkg/es/mocks/IndicesExistsService.go b/pkg/es/mocks/IndicesExistsService.go index 0639710b76d..255c2ed88af 100644 --- a/pkg/es/mocks/IndicesExistsService.go +++ b/pkg/es/mocks/IndicesExistsService.go @@ -14,7 +14,6 @@ // See the License for the specific language governing permissions and // limitations under the License. - package mocks import ( diff --git a/pkg/es/mocks/MultiSearchService.go b/pkg/es/mocks/MultiSearchService.go index 3e4c9ab58e7..66b161585b0 100644 --- a/pkg/es/mocks/MultiSearchService.go +++ b/pkg/es/mocks/MultiSearchService.go @@ -14,7 +14,6 @@ // See the License for the specific language governing permissions and // limitations under the License. - package mocks import ( diff --git a/pkg/es/mocks/SearchService.go b/pkg/es/mocks/SearchService.go index 66c385e212a..6e97df17d89 100644 --- a/pkg/es/mocks/SearchService.go +++ b/pkg/es/mocks/SearchService.go @@ -14,7 +14,6 @@ // See the License for the specific language governing permissions and // limitations under the License. - package mocks import ( diff --git a/pkg/es/mocks/TemplateApplier.go b/pkg/es/mocks/TemplateApplier.go index 5deaaefb855..8b678e3cbf3 100644 --- a/pkg/es/mocks/TemplateApplier.go +++ b/pkg/es/mocks/TemplateApplier.go @@ -14,7 +14,6 @@ // See the License for the specific language governing permissions and // limitations under the License. - package mocks import ( diff --git a/pkg/es/mocks/TemplateBuilder.go b/pkg/es/mocks/TemplateBuilder.go index b8f1ab45789..5c4b43b0561 100644 --- a/pkg/es/mocks/TemplateBuilder.go +++ b/pkg/es/mocks/TemplateBuilder.go @@ -14,7 +14,6 @@ // See the License for the specific language governing permissions and // limitations under the License. - package mocks import ( diff --git a/pkg/es/mocks/TemplateCreateService.go b/pkg/es/mocks/TemplateCreateService.go index cdcb157141e..b9c55813287 100644 --- a/pkg/es/mocks/TemplateCreateService.go +++ b/pkg/es/mocks/TemplateCreateService.go @@ -14,7 +14,6 @@ // See the License for the specific language governing permissions and // limitations under the License. - package mocks import ( diff --git a/pkg/httpmetrics/metrics.go b/pkg/httpmetrics/metrics.go index d26d5ad958f..1c13a16efd8 100644 --- a/pkg/httpmetrics/metrics.go +++ b/pkg/httpmetrics/metrics.go @@ -20,7 +20,7 @@ import ( "sync" "time" - "github.com/uber/jaeger-lib/metrics" + "github.com/jaegertracing/jaeger/pkg/metrics" ) type statusRecorder struct { diff --git a/pkg/httpmetrics/metrics_test.go b/pkg/httpmetrics/metrics_test.go index 544c9550c5c..d0971246759 100644 --- a/pkg/httpmetrics/metrics_test.go +++ b/pkg/httpmetrics/metrics_test.go @@ -21,7 +21,8 @@ import ( "time" "github.com/stretchr/testify/assert" - "github.com/uber/jaeger-lib/metrics/metricstest" + + "github.com/jaegertracing/jaeger/internal/metricstest" ) func TestNewMetricsHandler(t *testing.T) { diff --git a/pkg/metrics/builder.go b/pkg/metrics/builder.go index ce5dc08a953..16a6672bfba 100644 --- a/pkg/metrics/builder.go +++ b/pkg/metrics/builder.go @@ -67,19 +67,19 @@ func (b *Builder) InitFromViper(v *viper.Viper) *Builder { // CreateMetricsFactory creates a metrics factory based on the configured type of the backend. // If the metrics backend supports HTTP endpoint for scraping, it is stored in the builder and // can be later added by RegisterHandler function. -func (b *Builder) CreateMetricsFactory(namespace string) (metrics.Factory, error) { +func (b *Builder) CreateMetricsFactory(namespace string) (Factory, error) { if b.Backend == "prometheus" { metricsFactory := jprom.New().Namespace(metrics.NSOptions{Name: namespace, Tags: nil}) b.handler = promhttp.HandlerFor(prometheus.DefaultGatherer, promhttp.HandlerOpts{DisableCompression: true}) - return metricsFactory, nil + return NewJLibAdapter(metricsFactory), nil } if b.Backend == "expvar" { metricsFactory := jexpvar.NewFactory(10).Namespace(metrics.NSOptions{Name: namespace, Tags: nil}) b.handler = expvar.Handler() - return metricsFactory, nil + return NewJLibAdapter(metricsFactory), nil } if b.Backend == "none" || b.Backend == "" { - return metrics.NullFactory, nil + return NullFactory, nil } return nil, errUnknownBackend } @@ -88,3 +88,60 @@ func (b *Builder) CreateMetricsFactory(namespace string) (metrics.Factory, error func (b *Builder) Handler() http.Handler { return b.handler } + +// JLibAdapter is temporary type used to bridge metrics API in this package +// with that of jaeger-lib. +type JLibAdapter struct { + f metrics.Factory +} + +var _ Factory = (*JLibAdapter)(nil) + +func NewJLibAdapter(f metrics.Factory) *JLibAdapter { + return &JLibAdapter{f: f} +} + +func (a *JLibAdapter) Counter(opts Options) Counter { + return a.f.Counter(metrics.Options{ + Name: opts.Name, + Tags: opts.Tags, + Help: opts.Help, + }) +} + +func (a *JLibAdapter) Timer(opts TimerOptions) Timer { + return a.f.Timer(metrics.TimerOptions{ + Name: opts.Name, + Tags: opts.Tags, + Help: opts.Help, + Buckets: opts.Buckets, + }) +} + +func (a *JLibAdapter) Gauge(opts Options) Gauge { + return a.f.Gauge(metrics.Options{ + Name: opts.Name, + Tags: opts.Tags, + Help: opts.Help, + }) +} + +func (a *JLibAdapter) Histogram(opts HistogramOptions) Histogram { + return a.f.Histogram(metrics.HistogramOptions{ + Name: opts.Name, + Tags: opts.Tags, + Help: opts.Help, + Buckets: opts.Buckets, + }) +} + +func (a *JLibAdapter) Namespace(opts NSOptions) Factory { + return &JLibAdapter{f: a.f.Namespace(metrics.NSOptions{ + Name: opts.Name, + Tags: opts.Tags, + })} +} + +func (a *JLibAdapter) Unwrap() metrics.Factory { + return a.f +} diff --git a/pkg/metrics/builder_test.go b/pkg/metrics/builder_test.go index 4e507ca6691..df4c1ed02f5 100644 --- a/pkg/metrics/builder_test.go +++ b/pkg/metrics/builder_test.go @@ -114,7 +114,7 @@ func TestBuilder(t *testing.T) { continue } require.NotNil(t, mf) - mf.Counter(metrics.Options{Name: "counter", Tags: nil}).Inc(1) + mf.Counter(Options{Name: "counter", Tags: nil}).Inc(1) if testCase.assert != nil { testCase.assert() } @@ -123,3 +123,13 @@ func TestBuilder(t *testing.T) { } } } + +func TestJLibAdapter(t *testing.T) { + f := NewJLibAdapter(metrics.NullFactory) + f.Counter(Options{}) + f.Timer(TimerOptions{}) + f.Gauge(Options{}) + f.Histogram(HistogramOptions{}) + f.Namespace(NSOptions{}) + f.Unwrap() +} diff --git a/pkg/metrics/counter.go b/pkg/metrics/counter.go new file mode 100644 index 00000000000..e594940857e --- /dev/null +++ b/pkg/metrics/counter.go @@ -0,0 +1,29 @@ +// Copyright (c) 2022 The Jaeger Authors. +// Copyright (c) 2017 Uber Technologies, Inc. +// +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// 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. + +package metrics + +// Counter tracks the number of times an event has occurred +type Counter interface { + // Inc adds the given value to the counter. + Inc(int64) +} + +// NullCounter counter that does nothing +var NullCounter Counter = nullCounter{} + +type nullCounter struct{} + +func (nullCounter) Inc(int64) {} diff --git a/pkg/metrics/factory.go b/pkg/metrics/factory.go new file mode 100644 index 00000000000..e77257127d9 --- /dev/null +++ b/pkg/metrics/factory.go @@ -0,0 +1,82 @@ +// Copyright (c) 2022 The Jaeger Authors. +// Copyright (c) 2017 Uber Technologies, Inc. +// +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// 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. + +package metrics + +import ( + "time" +) + +// NSOptions defines the name and tags map associated with a factory namespace +type NSOptions struct { + Name string + Tags map[string]string +} + +// Options defines the information associated with a metric +type Options struct { + Name string + Tags map[string]string + Help string +} + +// TimerOptions defines the information associated with a metric +type TimerOptions struct { + Name string + Tags map[string]string + Help string + Buckets []time.Duration +} + +// HistogramOptions defines the information associated with a metric +type HistogramOptions struct { + Name string + Tags map[string]string + Help string + Buckets []float64 +} + +// Factory creates new metrics +type Factory interface { + Counter(metric Options) Counter + Timer(metric TimerOptions) Timer + Gauge(metric Options) Gauge + Histogram(metric HistogramOptions) Histogram + + // Namespace returns a nested metrics factory. + Namespace(scope NSOptions) Factory +} + +// NullFactory is a metrics factory that returns NullCounter, NullTimer, and NullGauge. +var NullFactory Factory = nullFactory{} + +type nullFactory struct{} + +func (nullFactory) Counter(options Options) Counter { + return NullCounter +} + +func (nullFactory) Timer(options TimerOptions) Timer { + return NullTimer +} + +func (nullFactory) Gauge(options Options) Gauge { + return NullGauge +} + +func (nullFactory) Histogram(options HistogramOptions) Histogram { + return NullHistogram +} +func (nullFactory) Namespace(scope NSOptions) Factory { return NullFactory } diff --git a/pkg/metrics/gauge.go b/pkg/metrics/gauge.go new file mode 100644 index 00000000000..53631d451d6 --- /dev/null +++ b/pkg/metrics/gauge.go @@ -0,0 +1,29 @@ +// Copyright (c) 2022 The Jaeger Authors. +// Copyright (c) 2017 Uber Technologies, Inc. +// +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// 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. + +package metrics + +// Gauge returns instantaneous measurements of something as an int64 value +type Gauge interface { + // Update the gauge to the value passed in. + Update(int64) +} + +// NullGauge gauge that does nothing +var NullGauge Gauge = nullGauge{} + +type nullGauge struct{} + +func (nullGauge) Update(int64) {} diff --git a/pkg/metrics/histogram.go b/pkg/metrics/histogram.go new file mode 100644 index 00000000000..d3bd6174fe8 --- /dev/null +++ b/pkg/metrics/histogram.go @@ -0,0 +1,28 @@ +// Copyright (c) 2018 The Jaeger Authors +// +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// 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. + +package metrics + +// Histogram that keeps track of a distribution of values. +type Histogram interface { + // Records the value passed in. + Record(float64) +} + +// NullHistogram that does nothing +var NullHistogram Histogram = nullHistogram{} + +type nullHistogram struct{} + +func (nullHistogram) Record(float64) {} diff --git a/pkg/metrics/metrics.go b/pkg/metrics/metrics.go new file mode 100644 index 00000000000..1012cbf9d0a --- /dev/null +++ b/pkg/metrics/metrics.go @@ -0,0 +1,138 @@ +// Copyright (c) 2022 The Jaeger Authors. +// Copyright (c) 2017 Uber Technologies, Inc. +// +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// 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. + +package metrics + +import ( + "fmt" + "reflect" + "strconv" + "strings" +) + +// MustInit initializes the passed in metrics and initializes its fields using the passed in factory. +// +// It uses reflection to initialize a struct containing metrics fields +// by assigning new Counter/Gauge/Timer values with the metric name retrieved +// from the `metric` tag and stats tags retrieved from the `tags` tag. +// +// Note: all fields of the struct must be exported, have a `metric` tag, and be +// of type Counter or Gauge or Timer. +// +// Errors during Init lead to a panic. +func MustInit(metrics interface{}, factory Factory, globalTags map[string]string) { + if err := Init(metrics, factory, globalTags); err != nil { + panic(err.Error()) + } +} + +// Init does the same as MustInit, but returns an error instead of +// panicking. +func Init(m interface{}, factory Factory, globalTags map[string]string) error { + // Allow user to opt out of reporting metrics by passing in nil. + if factory == nil { + factory = NullFactory + } + + counterPtrType := reflect.TypeOf((*Counter)(nil)).Elem() + gaugePtrType := reflect.TypeOf((*Gauge)(nil)).Elem() + timerPtrType := reflect.TypeOf((*Timer)(nil)).Elem() + histogramPtrType := reflect.TypeOf((*Histogram)(nil)).Elem() + + v := reflect.ValueOf(m).Elem() + t := v.Type() + for i := 0; i < t.NumField(); i++ { + tags := make(map[string]string) + for k, v := range globalTags { + tags[k] = v + } + var buckets []float64 + field := t.Field(i) + metric := field.Tag.Get("metric") + if metric == "" { + return fmt.Errorf("Field %s is missing a tag 'metric'", field.Name) + } + if tagString := field.Tag.Get("tags"); tagString != "" { + tagPairs := strings.Split(tagString, ",") + for _, tagPair := range tagPairs { + tag := strings.Split(tagPair, "=") + if len(tag) != 2 { + return fmt.Errorf( + "Field [%s]: Tag [%s] is not of the form key=value in 'tags' string [%s]", + field.Name, tagPair, tagString) + } + tags[tag[0]] = tag[1] + } + } + if bucketString := field.Tag.Get("buckets"); bucketString != "" { + if field.Type.AssignableTo(timerPtrType) { + // TODO: Parse timer duration buckets + return fmt.Errorf( + "Field [%s]: Buckets are not currently initialized for timer metrics", + field.Name) + } else if field.Type.AssignableTo(histogramPtrType) { + bucketValues := strings.Split(bucketString, ",") + for _, bucket := range bucketValues { + b, err := strconv.ParseFloat(bucket, 64) + if err != nil { + return fmt.Errorf( + "Field [%s]: Bucket [%s] could not be converted to float64 in 'buckets' string [%s]", + field.Name, bucket, bucketString) + } + buckets = append(buckets, b) + } + } else { + return fmt.Errorf( + "Field [%s]: Buckets should only be defined for Timer and Histogram metric types", + field.Name) + } + } + help := field.Tag.Get("help") + var obj interface{} + if field.Type.AssignableTo(counterPtrType) { + obj = factory.Counter(Options{ + Name: metric, + Tags: tags, + Help: help, + }) + } else if field.Type.AssignableTo(gaugePtrType) { + obj = factory.Gauge(Options{ + Name: metric, + Tags: tags, + Help: help, + }) + } else if field.Type.AssignableTo(timerPtrType) { + // TODO: Add buckets once parsed (see TODO above) + obj = factory.Timer(TimerOptions{ + Name: metric, + Tags: tags, + Help: help, + }) + } else if field.Type.AssignableTo(histogramPtrType) { + obj = factory.Histogram(HistogramOptions{ + Name: metric, + Tags: tags, + Help: help, + Buckets: buckets, + }) + } else { + return fmt.Errorf( + "Field %s is not a pointer to timer, gauge, or counter", + field.Name) + } + v.Field(i).Set(reflect.ValueOf(obj)) + } + return nil +} diff --git a/pkg/metrics/metrics_test.go b/pkg/metrics/metrics_test.go new file mode 100644 index 00000000000..3a29bcaaf9a --- /dev/null +++ b/pkg/metrics/metrics_test.go @@ -0,0 +1,144 @@ +// Copyright (c) 2022 The Jaeger Authors. +// +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// 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. + +// Must use separate test package to break import cycle. +package metrics_test + +import ( + "testing" + "time" + + "github.com/stretchr/testify/assert" + + "github.com/jaegertracing/jaeger/internal/metricstest" + "github.com/jaegertracing/jaeger/pkg/metrics" +) + +func TestInitMetrics(t *testing.T) { + testMetrics := struct { + Gauge metrics.Gauge `metric:"gauge" tags:"1=one,2=two"` + Counter metrics.Counter `metric:"counter"` + Timer metrics.Timer `metric:"timer"` + Histogram metrics.Histogram `metric:"histogram" buckets:"20,40,60,80"` + }{} + + f := metricstest.NewFactory(0) + defer f.Stop() + + globalTags := map[string]string{"key": "value"} + + err := metrics.Init(&testMetrics, f, globalTags) + assert.NoError(t, err) + + testMetrics.Gauge.Update(10) + testMetrics.Counter.Inc(5) + testMetrics.Timer.Record(time.Duration(time.Second * 35)) + testMetrics.Histogram.Record(42) + + // wait for metrics + for i := 0; i < 1000; i++ { + c, _ := f.Snapshot() + if _, ok := c["counter"]; ok { + break + } + time.Sleep(1 * time.Millisecond) + } + + c, g := f.Snapshot() + + assert.EqualValues(t, 5, c["counter|key=value"]) + assert.EqualValues(t, 10, g["gauge|1=one|2=two|key=value"]) + assert.EqualValues(t, 36863, g["timer|key=value.P50"]) + assert.EqualValues(t, 43, g["histogram|key=value.P50"]) + + stopwatch := metrics.StartStopwatch(testMetrics.Timer) + stopwatch.Stop() + assert.True(t, 0 < stopwatch.ElapsedTime()) +} + +var ( + noMetricTag = struct { + NoMetricTag metrics.Counter + }{} + + badTags = struct { + BadTags metrics.Counter `metric:"counter" tags:"1=one,noValue"` + }{} + + invalidMetricType = struct { + InvalidMetricType int64 `metric:"counter"` + }{} + + badHistogramBucket = struct { + BadHistogramBucket metrics.Histogram `metric:"histogram" buckets:"1,2,a,4"` + }{} + + badTimerBucket = struct { + BadTimerBucket metrics.Timer `metric:"timer" buckets:"1"` + }{} + + invalidBuckets = struct { + InvalidBuckets metrics.Counter `metric:"counter" buckets:"1"` + }{} +) + +func TestInitMetricsFailures(t *testing.T) { + assert.EqualError(t, metrics.Init(&noMetricTag, nil, nil), "Field NoMetricTag is missing a tag 'metric'") + + assert.EqualError(t, metrics.Init(&badTags, nil, nil), + "Field [BadTags]: Tag [noValue] is not of the form key=value in 'tags' string [1=one,noValue]") + + assert.EqualError(t, metrics.Init(&invalidMetricType, nil, nil), + "Field InvalidMetricType is not a pointer to timer, gauge, or counter") + + assert.EqualError(t, metrics.Init(&badHistogramBucket, nil, nil), + "Field [BadHistogramBucket]: Bucket [a] could not be converted to float64 in 'buckets' string [1,2,a,4]") + + assert.EqualError(t, metrics.Init(&badTimerBucket, nil, nil), + "Field [BadTimerBucket]: Buckets are not currently initialized for timer metrics") + + assert.EqualError(t, metrics.Init(&invalidBuckets, nil, nil), + "Field [InvalidBuckets]: Buckets should only be defined for Timer and Histogram metric types") +} + +func TestInitPanic(t *testing.T) { + defer func() { + if r := recover(); r == nil { + t.Error("The code did not panic") + } + }() + + metrics.MustInit(&noMetricTag, metrics.NullFactory, nil) +} + +func TestNullMetrics(t *testing.T) { + // This test is just for cover + metrics.NullFactory.Timer(metrics.TimerOptions{ + Name: "name", + }).Record(0) + metrics.NullFactory.Counter(metrics.Options{ + Name: "name", + }).Inc(0) + metrics.NullFactory.Gauge(metrics.Options{ + Name: "name", + }).Update(0) + metrics.NullFactory.Histogram(metrics.HistogramOptions{ + Name: "name", + }).Record(0) + metrics.NullFactory.Namespace(metrics.NSOptions{ + Name: "name", + }).Gauge(metrics.Options{ + Name: "name2", + }).Update(0) +} diff --git a/pkg/metrics/package.go b/pkg/metrics/package.go index 7bcb53d1219..9764382db10 100644 --- a/pkg/metrics/package.go +++ b/pkg/metrics/package.go @@ -13,5 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Package metrics provides command line flags for configuring the metrics backend. +// Package metrics provides an internal abstraction for metrics API, +// and command line flags for configuring the metrics backend. package metrics diff --git a/pkg/metrics/stopwatch.go b/pkg/metrics/stopwatch.go new file mode 100644 index 00000000000..0ca70979260 --- /dev/null +++ b/pkg/metrics/stopwatch.go @@ -0,0 +1,44 @@ +// Copyright (c) 2022 The Jaeger Authors. +// Copyright (c) 2017 Uber Technologies, Inc. +// +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// 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. + +package metrics + +import ( + "time" +) + +// StartStopwatch begins recording the executing time of an event, returning +// a Stopwatch that should be used to stop the recording the time for +// that event. Multiple events can be occurring simultaneously each +// represented by different active Stopwatches +func StartStopwatch(timer Timer) Stopwatch { + return Stopwatch{t: timer, start: time.Now()} +} + +// A Stopwatch tracks the execution time of a specific event +type Stopwatch struct { + t Timer + start time.Time +} + +// Stop stops executing of the stopwatch and records the amount of elapsed time +func (s Stopwatch) Stop() { + s.t.Record(s.ElapsedTime()) +} + +// ElapsedTime returns the amount of elapsed time (in time.Duration) +func (s Stopwatch) ElapsedTime() time.Duration { + return time.Since(s.start) +} diff --git a/pkg/metrics/timer.go b/pkg/metrics/timer.go new file mode 100644 index 00000000000..75df952d747 --- /dev/null +++ b/pkg/metrics/timer.go @@ -0,0 +1,34 @@ +// Copyright (c) 2022 The Jaeger Authors. +// Copyright (c) 2017 Uber Technologies, Inc. +// +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// 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. + +package metrics + +import ( + "time" +) + +// Timer accumulates observations about how long some operation took, +// and also maintains a historgam of percentiles. +type Timer interface { + // Records the time passed in. + Record(time.Duration) +} + +// NullTimer timer that does nothing +var NullTimer Timer = nullTimer{} + +type nullTimer struct{} + +func (nullTimer) Record(time.Duration) {} diff --git a/pkg/queue/bounded_queue.go b/pkg/queue/bounded_queue.go index 0ade4b02c7b..7d95ef14ce5 100644 --- a/pkg/queue/bounded_queue.go +++ b/pkg/queue/bounded_queue.go @@ -21,8 +21,9 @@ import ( "time" "unsafe" - "github.com/uber/jaeger-lib/metrics" uatomic "go.uber.org/atomic" + + "github.com/jaegertracing/jaeger/pkg/metrics" ) // Consumer consumes data from a bounded queue diff --git a/pkg/queue/bounded_queue_test.go b/pkg/queue/bounded_queue_test.go index 759ecc64fb2..b852f1667b0 100644 --- a/pkg/queue/bounded_queue_test.go +++ b/pkg/queue/bounded_queue_test.go @@ -25,9 +25,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/uber/jaeger-lib/metrics" - "github.com/uber/jaeger-lib/metrics/metricstest" uatomic "go.uber.org/atomic" + + "github.com/jaegertracing/jaeger/internal/metricstest" + "github.com/jaegertracing/jaeger/pkg/metrics" ) // In this test we run a queue with capacity 1 and a single consumer. diff --git a/pkg/version/build.go b/pkg/version/build.go index 5d9f2621edb..33438e23ef0 100644 --- a/pkg/version/build.go +++ b/pkg/version/build.go @@ -14,7 +14,7 @@ package version -import "github.com/uber/jaeger-lib/metrics" +import "github.com/jaegertracing/jaeger/pkg/metrics" var ( // commitFromGit is a constant representing the source version that diff --git a/plugin/sampling/strategystore/adaptive/aggregator.go b/plugin/sampling/strategystore/adaptive/aggregator.go index 26cc3c5e60b..2b76a3c7076 100644 --- a/plugin/sampling/strategystore/adaptive/aggregator.go +++ b/plugin/sampling/strategystore/adaptive/aggregator.go @@ -19,10 +19,10 @@ import ( "time" "github.com/uber/jaeger-client-go" - "github.com/uber/jaeger-lib/metrics" "github.com/jaegertracing/jaeger/cmd/collector/app/sampling/model" "github.com/jaegertracing/jaeger/cmd/collector/app/sampling/strategystore" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/storage/samplingstore" ) diff --git a/plugin/sampling/strategystore/adaptive/aggregator_test.go b/plugin/sampling/strategystore/adaptive/aggregator_test.go index cc7fe0176fa..c2abee7e75d 100644 --- a/plugin/sampling/strategystore/adaptive/aggregator_test.go +++ b/plugin/sampling/strategystore/adaptive/aggregator_test.go @@ -20,8 +20,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "github.com/uber/jaeger-lib/metrics/metricstest" + "github.com/jaegertracing/jaeger/internal/metricstest" "github.com/jaegertracing/jaeger/storage/samplingstore/mocks" ) diff --git a/plugin/sampling/strategystore/adaptive/factory.go b/plugin/sampling/strategystore/adaptive/factory.go index 01d1f0feb27..d45f8e61f9b 100644 --- a/plugin/sampling/strategystore/adaptive/factory.go +++ b/plugin/sampling/strategystore/adaptive/factory.go @@ -19,11 +19,11 @@ import ( "flag" "github.com/spf13/viper" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/cmd/collector/app/sampling/strategystore" "github.com/jaegertracing/jaeger/pkg/distributedlock" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/plugin" "github.com/jaegertracing/jaeger/storage" "github.com/jaegertracing/jaeger/storage/samplingstore" diff --git a/plugin/sampling/strategystore/adaptive/factory_test.go b/plugin/sampling/strategystore/adaptive/factory_test.go index 2f96aeb0338..ff81118d4d4 100644 --- a/plugin/sampling/strategystore/adaptive/factory_test.go +++ b/plugin/sampling/strategystore/adaptive/factory_test.go @@ -21,7 +21,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/cmd/collector/app/sampling/model" @@ -29,6 +28,7 @@ import ( "github.com/jaegertracing/jaeger/pkg/config" "github.com/jaegertracing/jaeger/pkg/distributedlock" lmocks "github.com/jaegertracing/jaeger/pkg/distributedlock/mocks" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/plugin" "github.com/jaegertracing/jaeger/storage/samplingstore" smocks "github.com/jaegertracing/jaeger/storage/samplingstore/mocks" diff --git a/plugin/sampling/strategystore/adaptive/processor.go b/plugin/sampling/strategystore/adaptive/processor.go index 119af6b3b7f..2eb84a8a071 100644 --- a/plugin/sampling/strategystore/adaptive/processor.go +++ b/plugin/sampling/strategystore/adaptive/processor.go @@ -22,10 +22,10 @@ import ( "sync" "time" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/cmd/collector/app/sampling/model" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/plugin/sampling/calculationstrategy" "github.com/jaegertracing/jaeger/plugin/sampling/leaderelection" "github.com/jaegertracing/jaeger/storage/samplingstore" diff --git a/plugin/sampling/strategystore/adaptive/processor_test.go b/plugin/sampling/strategystore/adaptive/processor_test.go index 063627c639a..eab2880be10 100644 --- a/plugin/sampling/strategystore/adaptive/processor_test.go +++ b/plugin/sampling/strategystore/adaptive/processor_test.go @@ -23,11 +23,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - "github.com/uber/jaeger-lib/metrics" - "github.com/uber/jaeger-lib/metrics/metricstest" "go.uber.org/zap" "github.com/jaegertracing/jaeger/cmd/collector/app/sampling/model" + "github.com/jaegertracing/jaeger/internal/metricstest" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/pkg/testutils" "github.com/jaegertracing/jaeger/plugin/sampling/calculationstrategy" epmocks "github.com/jaegertracing/jaeger/plugin/sampling/leaderelection/mocks" diff --git a/plugin/sampling/strategystore/adaptive/strategy_store.go b/plugin/sampling/strategystore/adaptive/strategy_store.go index c47e01aaf12..76d2b9f5d5e 100644 --- a/plugin/sampling/strategystore/adaptive/strategy_store.go +++ b/plugin/sampling/strategystore/adaptive/strategy_store.go @@ -15,11 +15,11 @@ package adaptive import ( - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/pkg/distributedlock" "github.com/jaegertracing/jaeger/pkg/hostname" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/plugin/sampling/leaderelection" "github.com/jaegertracing/jaeger/storage/samplingstore" ) diff --git a/plugin/sampling/strategystore/factory.go b/plugin/sampling/strategystore/factory.go index 5cd9716a014..9cc2693e7bf 100644 --- a/plugin/sampling/strategystore/factory.go +++ b/plugin/sampling/strategystore/factory.go @@ -19,10 +19,10 @@ import ( "fmt" "github.com/spf13/viper" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/cmd/collector/app/sampling/strategystore" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/plugin" "github.com/jaegertracing/jaeger/plugin/sampling/strategystore/adaptive" "github.com/jaegertracing/jaeger/plugin/sampling/strategystore/static" diff --git a/plugin/sampling/strategystore/factory_test.go b/plugin/sampling/strategystore/factory_test.go index 874f547414c..1bf2886ffbe 100644 --- a/plugin/sampling/strategystore/factory_test.go +++ b/plugin/sampling/strategystore/factory_test.go @@ -24,11 +24,11 @@ import ( "github.com/spf13/viper" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" ss "github.com/jaegertracing/jaeger/cmd/collector/app/sampling/strategystore" "github.com/jaegertracing/jaeger/pkg/distributedlock" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/plugin" "github.com/jaegertracing/jaeger/storage" "github.com/jaegertracing/jaeger/storage/samplingstore" diff --git a/plugin/sampling/strategystore/static/factory.go b/plugin/sampling/strategystore/static/factory.go index 01dc0d9477d..91aa46e6d9c 100644 --- a/plugin/sampling/strategystore/static/factory.go +++ b/plugin/sampling/strategystore/static/factory.go @@ -18,10 +18,10 @@ import ( "flag" "github.com/spf13/viper" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/cmd/collector/app/sampling/strategystore" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/plugin" "github.com/jaegertracing/jaeger/storage" ) diff --git a/plugin/sampling/strategystore/static/factory_test.go b/plugin/sampling/strategystore/static/factory_test.go index 1585d7598e1..9a7be64ac22 100644 --- a/plugin/sampling/strategystore/static/factory_test.go +++ b/plugin/sampling/strategystore/static/factory_test.go @@ -18,11 +18,11 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" ss "github.com/jaegertracing/jaeger/cmd/collector/app/sampling/strategystore" "github.com/jaegertracing/jaeger/pkg/config" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/plugin" ) diff --git a/plugin/storage/badger/dependencystore/storage_test.go b/plugin/storage/badger/dependencystore/storage_test.go index 5042e6c4443..b966b99b506 100644 --- a/plugin/storage/badger/dependencystore/storage_test.go +++ b/plugin/storage/badger/dependencystore/storage_test.go @@ -22,11 +22,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/model" "github.com/jaegertracing/jaeger/pkg/config" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/plugin/storage/badger" "github.com/jaegertracing/jaeger/storage/dependencystore" "github.com/jaegertracing/jaeger/storage/spanstore" diff --git a/plugin/storage/badger/factory.go b/plugin/storage/badger/factory.go index 598a97439b1..b5665e0b176 100644 --- a/plugin/storage/badger/factory.go +++ b/plugin/storage/badger/factory.go @@ -24,9 +24,9 @@ import ( "github.com/dgraph-io/badger/v3" "github.com/spf13/viper" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/plugin" depStore "github.com/jaegertracing/jaeger/plugin/storage/badger/dependencystore" badgerStore "github.com/jaegertracing/jaeger/plugin/storage/badger/spanstore" diff --git a/plugin/storage/badger/factory_test.go b/plugin/storage/badger/factory_test.go index 503919ef562..9a78c0bb4f1 100644 --- a/plugin/storage/badger/factory_test.go +++ b/plugin/storage/badger/factory_test.go @@ -23,11 +23,11 @@ import ( "time" assert "github.com/stretchr/testify/require" - "github.com/uber/jaeger-lib/metrics" - "github.com/uber/jaeger-lib/metrics/metricstest" "go.uber.org/zap" + "github.com/jaegertracing/jaeger/internal/metricstest" "github.com/jaegertracing/jaeger/pkg/config" + "github.com/jaegertracing/jaeger/pkg/metrics" ) func TestInitializationErrors(t *testing.T) { diff --git a/plugin/storage/badger/spanstore/read_write_test.go b/plugin/storage/badger/spanstore/read_write_test.go index 51800ae8d73..064419dd761 100644 --- a/plugin/storage/badger/spanstore/read_write_test.go +++ b/plugin/storage/badger/spanstore/read_write_test.go @@ -27,11 +27,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/model" "github.com/jaegertracing/jaeger/pkg/config" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/plugin/storage/badger" "github.com/jaegertracing/jaeger/storage/spanstore" ) diff --git a/plugin/storage/badger/stats_linux_test.go b/plugin/storage/badger/stats_linux_test.go index 9b27cb7f77b..09c49c7021a 100644 --- a/plugin/storage/badger/stats_linux_test.go +++ b/plugin/storage/badger/stats_linux_test.go @@ -18,9 +18,9 @@ import ( "testing" assert "github.com/stretchr/testify/require" - "github.com/uber/jaeger-lib/metrics/metricstest" "go.uber.org/zap" + "github.com/jaegertracing/jaeger/internal/metricstest" "github.com/jaegertracing/jaeger/pkg/config" ) diff --git a/plugin/storage/badger/stats_test.go b/plugin/storage/badger/stats_test.go index 680efd90f17..7a3a803b595 100644 --- a/plugin/storage/badger/stats_test.go +++ b/plugin/storage/badger/stats_test.go @@ -21,10 +21,10 @@ import ( "testing" assert "github.com/stretchr/testify/require" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/pkg/config" + "github.com/jaegertracing/jaeger/pkg/metrics" ) func TestDiskStatisticsUpdate(t *testing.T) { diff --git a/plugin/storage/cassandra/dependencystore/storage.go b/plugin/storage/cassandra/dependencystore/storage.go index 71e7d56d23f..7906f63c552 100644 --- a/plugin/storage/cassandra/dependencystore/storage.go +++ b/plugin/storage/cassandra/dependencystore/storage.go @@ -21,12 +21,12 @@ import ( "fmt" "time" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/model" "github.com/jaegertracing/jaeger/pkg/cassandra" casMetrics "github.com/jaegertracing/jaeger/pkg/cassandra/metrics" + "github.com/jaegertracing/jaeger/pkg/metrics" ) // Version determines which version of the dependencies table to use. diff --git a/plugin/storage/cassandra/dependencystore/storage_test.go b/plugin/storage/cassandra/dependencystore/storage_test.go index 93f5e0d34b0..305a127649f 100644 --- a/plugin/storage/cassandra/dependencystore/storage_test.go +++ b/plugin/storage/cassandra/dependencystore/storage_test.go @@ -24,13 +24,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "github.com/uber/jaeger-lib/metrics" - "github.com/uber/jaeger-lib/metrics/metricstest" "go.uber.org/zap" + "github.com/jaegertracing/jaeger/internal/metricstest" "github.com/jaegertracing/jaeger/model" "github.com/jaegertracing/jaeger/pkg/cassandra" "github.com/jaegertracing/jaeger/pkg/cassandra/mocks" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/pkg/testutils" "github.com/jaegertracing/jaeger/storage/dependencystore" ) diff --git a/plugin/storage/cassandra/factory.go b/plugin/storage/cassandra/factory.go index 3cc28d395f6..507f847ebd5 100644 --- a/plugin/storage/cassandra/factory.go +++ b/plugin/storage/cassandra/factory.go @@ -21,13 +21,13 @@ import ( "io" "github.com/spf13/viper" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/pkg/cassandra" "github.com/jaegertracing/jaeger/pkg/cassandra/config" "github.com/jaegertracing/jaeger/pkg/distributedlock" "github.com/jaegertracing/jaeger/pkg/hostname" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/plugin" cLock "github.com/jaegertracing/jaeger/plugin/pkg/distributedlock/cassandra" cDepStore "github.com/jaegertracing/jaeger/plugin/storage/cassandra/dependencystore" diff --git a/plugin/storage/cassandra/factory_test.go b/plugin/storage/cassandra/factory_test.go index dbe9111c658..9108ed35356 100644 --- a/plugin/storage/cassandra/factory_test.go +++ b/plugin/storage/cassandra/factory_test.go @@ -21,12 +21,12 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/pkg/cassandra" "github.com/jaegertracing/jaeger/pkg/cassandra/mocks" "github.com/jaegertracing/jaeger/pkg/config" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/pkg/testutils" "github.com/jaegertracing/jaeger/storage" ) diff --git a/plugin/storage/cassandra/samplingstore/storage.go b/plugin/storage/cassandra/samplingstore/storage.go index 5c2d2b50da8..2ccdc846fa1 100644 --- a/plugin/storage/cassandra/samplingstore/storage.go +++ b/plugin/storage/cassandra/samplingstore/storage.go @@ -25,12 +25,12 @@ import ( "time" "github.com/gocql/gocql" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/cmd/collector/app/sampling/model" "github.com/jaegertracing/jaeger/pkg/cassandra" casMetrics "github.com/jaegertracing/jaeger/pkg/cassandra/metrics" + "github.com/jaegertracing/jaeger/pkg/metrics" ) const ( diff --git a/plugin/storage/cassandra/samplingstore/storage_test.go b/plugin/storage/cassandra/samplingstore/storage_test.go index 54073dafff6..c6a21bb0268 100644 --- a/plugin/storage/cassandra/samplingstore/storage_test.go +++ b/plugin/storage/cassandra/samplingstore/storage_test.go @@ -23,10 +23,10 @@ import ( "github.com/gocql/gocql" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "github.com/uber/jaeger-lib/metrics/metricstest" "go.uber.org/zap" "github.com/jaegertracing/jaeger/cmd/collector/app/sampling/model" + "github.com/jaegertracing/jaeger/internal/metricstest" "github.com/jaegertracing/jaeger/pkg/cassandra/mocks" "github.com/jaegertracing/jaeger/pkg/testutils" "github.com/jaegertracing/jaeger/storage/samplingstore" diff --git a/plugin/storage/cassandra/savetracetest/main.go b/plugin/storage/cassandra/savetracetest/main.go index 0cdfab8ef09..8b28858b3e4 100644 --- a/plugin/storage/cassandra/savetracetest/main.go +++ b/plugin/storage/cassandra/savetracetest/main.go @@ -19,11 +19,11 @@ import ( "context" "time" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/model" cascfg "github.com/jaegertracing/jaeger/pkg/cassandra/config" + "github.com/jaegertracing/jaeger/pkg/metrics" cSpanStore "github.com/jaegertracing/jaeger/plugin/storage/cassandra/spanstore" "github.com/jaegertracing/jaeger/storage/spanstore" ) diff --git a/plugin/storage/cassandra/spanstore/operation_names.go b/plugin/storage/cassandra/spanstore/operation_names.go index e3883b8a488..167dcbd1c19 100644 --- a/plugin/storage/cassandra/spanstore/operation_names.go +++ b/plugin/storage/cassandra/spanstore/operation_names.go @@ -19,12 +19,12 @@ import ( "fmt" "time" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/pkg/cache" "github.com/jaegertracing/jaeger/pkg/cassandra" casMetrics "github.com/jaegertracing/jaeger/pkg/cassandra/metrics" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/plugin/storage/cassandra/spanstore/dbmodel" "github.com/jaegertracing/jaeger/storage/spanstore" ) diff --git a/plugin/storage/cassandra/spanstore/operation_names_test.go b/plugin/storage/cassandra/spanstore/operation_names_test.go index 8a3cfa5b549..134d501502d 100644 --- a/plugin/storage/cassandra/spanstore/operation_names_test.go +++ b/plugin/storage/cassandra/spanstore/operation_names_test.go @@ -23,9 +23,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "github.com/uber/jaeger-lib/metrics/metricstest" "go.uber.org/zap" + "github.com/jaegertracing/jaeger/internal/metricstest" "github.com/jaegertracing/jaeger/pkg/cassandra/mocks" "github.com/jaegertracing/jaeger/pkg/testutils" "github.com/jaegertracing/jaeger/plugin/storage/cassandra/spanstore/dbmodel" diff --git a/plugin/storage/cassandra/spanstore/reader.go b/plugin/storage/cassandra/spanstore/reader.go index b080bb1b847..621e327a41c 100644 --- a/plugin/storage/cassandra/spanstore/reader.go +++ b/plugin/storage/cassandra/spanstore/reader.go @@ -24,12 +24,12 @@ import ( "github.com/opentracing/opentracing-go" ottag "github.com/opentracing/opentracing-go/ext" otlog "github.com/opentracing/opentracing-go/log" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/model" "github.com/jaegertracing/jaeger/pkg/cassandra" casMetrics "github.com/jaegertracing/jaeger/pkg/cassandra/metrics" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/plugin/storage/cassandra/spanstore/dbmodel" "github.com/jaegertracing/jaeger/storage/spanstore" ) diff --git a/plugin/storage/cassandra/spanstore/reader_test.go b/plugin/storage/cassandra/spanstore/reader_test.go index 5372de6cd55..83e509f361b 100644 --- a/plugin/storage/cassandra/spanstore/reader_test.go +++ b/plugin/storage/cassandra/spanstore/reader_test.go @@ -25,9 +25,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - "github.com/uber/jaeger-lib/metrics/metricstest" "go.uber.org/zap" + "github.com/jaegertracing/jaeger/internal/metricstest" "github.com/jaegertracing/jaeger/model" "github.com/jaegertracing/jaeger/pkg/cassandra" "github.com/jaegertracing/jaeger/pkg/cassandra/mocks" diff --git a/plugin/storage/cassandra/spanstore/service_names.go b/plugin/storage/cassandra/spanstore/service_names.go index 98dc192d78f..6013573d64b 100644 --- a/plugin/storage/cassandra/spanstore/service_names.go +++ b/plugin/storage/cassandra/spanstore/service_names.go @@ -19,12 +19,12 @@ import ( "fmt" "time" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/pkg/cache" "github.com/jaegertracing/jaeger/pkg/cassandra" casMetrics "github.com/jaegertracing/jaeger/pkg/cassandra/metrics" + "github.com/jaegertracing/jaeger/pkg/metrics" ) const ( diff --git a/plugin/storage/cassandra/spanstore/service_names_test.go b/plugin/storage/cassandra/spanstore/service_names_test.go index 7345ea8e6b5..442f6e115b8 100644 --- a/plugin/storage/cassandra/spanstore/service_names_test.go +++ b/plugin/storage/cassandra/spanstore/service_names_test.go @@ -23,9 +23,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "github.com/uber/jaeger-lib/metrics/metricstest" "go.uber.org/zap" + "github.com/jaegertracing/jaeger/internal/metricstest" "github.com/jaegertracing/jaeger/pkg/cassandra/mocks" "github.com/jaegertracing/jaeger/pkg/testutils" ) diff --git a/plugin/storage/cassandra/spanstore/writer.go b/plugin/storage/cassandra/spanstore/writer.go index a8ac59fb7bb..0dffc8deeaa 100644 --- a/plugin/storage/cassandra/spanstore/writer.go +++ b/plugin/storage/cassandra/spanstore/writer.go @@ -23,12 +23,12 @@ import ( "time" "unicode/utf8" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/model" "github.com/jaegertracing/jaeger/pkg/cassandra" casMetrics "github.com/jaegertracing/jaeger/pkg/cassandra/metrics" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/plugin/storage/cassandra/spanstore/dbmodel" ) diff --git a/plugin/storage/cassandra/spanstore/writer_test.go b/plugin/storage/cassandra/spanstore/writer_test.go index 8365daf4308..8c901529d41 100644 --- a/plugin/storage/cassandra/spanstore/writer_test.go +++ b/plugin/storage/cassandra/spanstore/writer_test.go @@ -25,10 +25,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "github.com/uber/jaeger-lib/metrics/metricstest" "go.uber.org/atomic" "go.uber.org/zap" + "github.com/jaegertracing/jaeger/internal/metricstest" "github.com/jaegertracing/jaeger/model" "github.com/jaegertracing/jaeger/pkg/cassandra/mocks" "github.com/jaegertracing/jaeger/pkg/testutils" diff --git a/plugin/storage/es/factory.go b/plugin/storage/es/factory.go index 835311e7a70..cf98e692afb 100644 --- a/plugin/storage/es/factory.go +++ b/plugin/storage/es/factory.go @@ -21,11 +21,11 @@ import ( "io" "github.com/spf13/viper" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/pkg/es" "github.com/jaegertracing/jaeger/pkg/es/config" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/plugin" esDepStore "github.com/jaegertracing/jaeger/plugin/storage/es/dependencystore" "github.com/jaegertracing/jaeger/plugin/storage/es/mappings" diff --git a/plugin/storage/es/factory_test.go b/plugin/storage/es/factory_test.go index 57e696da8f9..23087ef48ef 100644 --- a/plugin/storage/es/factory_test.go +++ b/plugin/storage/es/factory_test.go @@ -23,13 +23,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/pkg/config" "github.com/jaegertracing/jaeger/pkg/es" escfg "github.com/jaegertracing/jaeger/pkg/es/config" "github.com/jaegertracing/jaeger/pkg/es/mocks" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/storage" ) diff --git a/plugin/storage/es/spanstore/reader.go b/plugin/storage/es/spanstore/reader.go index af4c834cbcd..0d6ccaa7c29 100644 --- a/plugin/storage/es/spanstore/reader.go +++ b/plugin/storage/es/spanstore/reader.go @@ -27,11 +27,11 @@ import ( "github.com/opentracing/opentracing-go" ottag "github.com/opentracing/opentracing-go/ext" otlog "github.com/opentracing/opentracing-go/log" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/model" "github.com/jaegertracing/jaeger/pkg/es" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/plugin/storage/es/spanstore/dbmodel" "github.com/jaegertracing/jaeger/storage/spanstore" ) diff --git a/plugin/storage/es/spanstore/reader_test.go b/plugin/storage/es/spanstore/reader_test.go index 7ae94baf1c1..f5366b7a3bd 100644 --- a/plugin/storage/es/spanstore/reader_test.go +++ b/plugin/storage/es/spanstore/reader_test.go @@ -29,9 +29,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - "github.com/uber/jaeger-lib/metrics/metricstest" "go.uber.org/zap" + "github.com/jaegertracing/jaeger/internal/metricstest" "github.com/jaegertracing/jaeger/model" "github.com/jaegertracing/jaeger/pkg/es/mocks" "github.com/jaegertracing/jaeger/pkg/testutils" diff --git a/plugin/storage/es/spanstore/writer.go b/plugin/storage/es/spanstore/writer.go index bf69ae07764..589e3464d86 100644 --- a/plugin/storage/es/spanstore/writer.go +++ b/plugin/storage/es/spanstore/writer.go @@ -20,12 +20,12 @@ import ( "strings" "time" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/model" "github.com/jaegertracing/jaeger/pkg/cache" "github.com/jaegertracing/jaeger/pkg/es" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/plugin/storage/es/spanstore/dbmodel" storageMetrics "github.com/jaegertracing/jaeger/storage/spanstore/metrics" ) diff --git a/plugin/storage/es/spanstore/writer_test.go b/plugin/storage/es/spanstore/writer_test.go index a0d972c41a3..69f1dea89fe 100644 --- a/plugin/storage/es/spanstore/writer_test.go +++ b/plugin/storage/es/spanstore/writer_test.go @@ -25,9 +25,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - "github.com/uber/jaeger-lib/metrics/metricstest" "go.uber.org/zap" + "github.com/jaegertracing/jaeger/internal/metricstest" "github.com/jaegertracing/jaeger/model" "github.com/jaegertracing/jaeger/pkg/es/mocks" "github.com/jaegertracing/jaeger/pkg/testutils" diff --git a/plugin/storage/factory.go b/plugin/storage/factory.go index 61f68ebede9..1e8c92b2fe9 100644 --- a/plugin/storage/factory.go +++ b/plugin/storage/factory.go @@ -21,9 +21,9 @@ import ( "io" "github.com/spf13/viper" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/pkg/multierror" "github.com/jaegertracing/jaeger/plugin" "github.com/jaegertracing/jaeger/plugin/storage/badger" diff --git a/plugin/storage/factory_test.go b/plugin/storage/factory_test.go index e6556f96364..66e6c086d38 100644 --- a/plugin/storage/factory_test.go +++ b/plugin/storage/factory_test.go @@ -28,12 +28,12 @@ import ( "github.com/spf13/viper" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/uber/jaeger-lib/metrics" - "github.com/uber/jaeger-lib/metrics/fork" - "github.com/uber/jaeger-lib/metrics/metricstest" "go.uber.org/zap" + "github.com/jaegertracing/jaeger/internal/metrics/fork" + "github.com/jaegertracing/jaeger/internal/metricstest" "github.com/jaegertracing/jaeger/pkg/config" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/storage" "github.com/jaegertracing/jaeger/storage/dependencystore" depStoreMocks "github.com/jaegertracing/jaeger/storage/dependencystore/mocks" diff --git a/plugin/storage/grpc/factory.go b/plugin/storage/grpc/factory.go index 5a28c2e3cf7..32c7f24dbbc 100644 --- a/plugin/storage/grpc/factory.go +++ b/plugin/storage/grpc/factory.go @@ -20,9 +20,9 @@ import ( "io" "github.com/spf13/viper" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/plugin" "github.com/jaegertracing/jaeger/plugin/storage/grpc/config" "github.com/jaegertracing/jaeger/plugin/storage/grpc/shared" diff --git a/plugin/storage/grpc/factory_test.go b/plugin/storage/grpc/factory_test.go index 2379f71b2a1..d157fac1f31 100644 --- a/plugin/storage/grpc/factory_test.go +++ b/plugin/storage/grpc/factory_test.go @@ -21,10 +21,10 @@ import ( "github.com/spf13/viper" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/pkg/config" + "github.com/jaegertracing/jaeger/pkg/metrics" grpcConfig "github.com/jaegertracing/jaeger/plugin/storage/grpc/config" "github.com/jaegertracing/jaeger/plugin/storage/grpc/mocks" "github.com/jaegertracing/jaeger/plugin/storage/grpc/shared" diff --git a/plugin/storage/integration/badgerstore_test.go b/plugin/storage/integration/badgerstore_test.go index 3aeb2b058dc..2f37f9bfa25 100644 --- a/plugin/storage/integration/badgerstore_test.go +++ b/plugin/storage/integration/badgerstore_test.go @@ -20,9 +20,9 @@ import ( "testing" assert "github.com/stretchr/testify/require" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/pkg/testutils" "github.com/jaegertracing/jaeger/plugin/storage/badger" ) diff --git a/plugin/storage/integration/cassandra_test.go b/plugin/storage/integration/cassandra_test.go index 76949d03d3d..dd7c3e984eb 100644 --- a/plugin/storage/integration/cassandra_test.go +++ b/plugin/storage/integration/cassandra_test.go @@ -25,11 +25,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/model" "github.com/jaegertracing/jaeger/pkg/config" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/pkg/testutils" "github.com/jaegertracing/jaeger/plugin/storage/cassandra" "github.com/jaegertracing/jaeger/storage/dependencystore" diff --git a/plugin/storage/integration/elasticsearch_test.go b/plugin/storage/integration/elasticsearch_test.go index 30ae0520e3d..0258a18cf65 100644 --- a/plugin/storage/integration/elasticsearch_test.go +++ b/plugin/storage/integration/elasticsearch_test.go @@ -28,12 +28,12 @@ import ( "github.com/olivere/elastic" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/model" estemplate "github.com/jaegertracing/jaeger/pkg/es" eswrapper "github.com/jaegertracing/jaeger/pkg/es/wrapper" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/pkg/testutils" "github.com/jaegertracing/jaeger/plugin/storage/es/dependencystore" "github.com/jaegertracing/jaeger/plugin/storage/es/mappings" diff --git a/plugin/storage/integration/grpc_test.go b/plugin/storage/integration/grpc_test.go index 53e5f821207..5b6504561cb 100644 --- a/plugin/storage/integration/grpc_test.go +++ b/plugin/storage/integration/grpc_test.go @@ -26,11 +26,11 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" googleGRPC "google.golang.org/grpc" "github.com/jaegertracing/jaeger/pkg/config" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/pkg/testutils" "github.com/jaegertracing/jaeger/plugin/storage/grpc" grpcMemory "github.com/jaegertracing/jaeger/plugin/storage/grpc/memory" diff --git a/plugin/storage/integration/kafka_test.go b/plugin/storage/integration/kafka_test.go index f515c7df39b..29f87a89545 100644 --- a/plugin/storage/integration/kafka_test.go +++ b/plugin/storage/integration/kafka_test.go @@ -22,13 +22,13 @@ import ( "time" "github.com/stretchr/testify/require" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/cmd/ingester/app" "github.com/jaegertracing/jaeger/cmd/ingester/app/builder" "github.com/jaegertracing/jaeger/model" "github.com/jaegertracing/jaeger/pkg/config" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/pkg/testutils" "github.com/jaegertracing/jaeger/plugin/storage/kafka" "github.com/jaegertracing/jaeger/plugin/storage/memory" diff --git a/plugin/storage/kafka/factory.go b/plugin/storage/kafka/factory.go index 1956ad751f1..8eb886fd2bb 100644 --- a/plugin/storage/kafka/factory.go +++ b/plugin/storage/kafka/factory.go @@ -21,10 +21,10 @@ import ( "github.com/Shopify/sarama" "github.com/spf13/viper" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/pkg/kafka/producer" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/plugin" "github.com/jaegertracing/jaeger/storage/dependencystore" "github.com/jaegertracing/jaeger/storage/spanstore" diff --git a/plugin/storage/kafka/factory_test.go b/plugin/storage/kafka/factory_test.go index 25cce84ec99..b51cd8a52f5 100644 --- a/plugin/storage/kafka/factory_test.go +++ b/plugin/storage/kafka/factory_test.go @@ -23,12 +23,12 @@ import ( "github.com/Shopify/sarama/mocks" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "go.uber.org/zap/zapcore" "github.com/jaegertracing/jaeger/pkg/config" kafkaConfig "github.com/jaegertracing/jaeger/pkg/kafka/producer" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/storage" ) diff --git a/plugin/storage/kafka/writer.go b/plugin/storage/kafka/writer.go index 03e23886fd8..9be38926b01 100644 --- a/plugin/storage/kafka/writer.go +++ b/plugin/storage/kafka/writer.go @@ -18,10 +18,10 @@ import ( "context" "github.com/Shopify/sarama" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/model" + "github.com/jaegertracing/jaeger/pkg/metrics" ) type spanWriterMetrics struct { diff --git a/plugin/storage/kafka/writer_test.go b/plugin/storage/kafka/writer_test.go index a9e2a12065c..3c65b9d570a 100644 --- a/plugin/storage/kafka/writer_test.go +++ b/plugin/storage/kafka/writer_test.go @@ -24,9 +24,9 @@ import ( saramaMocks "github.com/Shopify/sarama/mocks" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "github.com/uber/jaeger-lib/metrics/metricstest" "go.uber.org/zap" + "github.com/jaegertracing/jaeger/internal/metricstest" "github.com/jaegertracing/jaeger/model" "github.com/jaegertracing/jaeger/pkg/kafka/mocks" "github.com/jaegertracing/jaeger/storage/spanstore" diff --git a/plugin/storage/memory/factory.go b/plugin/storage/memory/factory.go index a3f4f165a7a..aa0282cbd86 100644 --- a/plugin/storage/memory/factory.go +++ b/plugin/storage/memory/factory.go @@ -19,10 +19,10 @@ import ( "flag" "github.com/spf13/viper" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/pkg/distributedlock" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/plugin" "github.com/jaegertracing/jaeger/storage/dependencystore" "github.com/jaegertracing/jaeger/storage/samplingstore" diff --git a/plugin/storage/memory/factory_test.go b/plugin/storage/memory/factory_test.go index 2a604e6a919..20f598abfe2 100644 --- a/plugin/storage/memory/factory_test.go +++ b/plugin/storage/memory/factory_test.go @@ -20,12 +20,12 @@ import ( "time" "github.com/stretchr/testify/assert" - "github.com/uber/jaeger-lib/metrics" - "github.com/uber/jaeger-lib/metrics/fork" - "github.com/uber/jaeger-lib/metrics/metricstest" "go.uber.org/zap" + "github.com/jaegertracing/jaeger/internal/metrics/fork" + "github.com/jaegertracing/jaeger/internal/metricstest" "github.com/jaegertracing/jaeger/pkg/config" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/storage" ) diff --git a/storage/factory.go b/storage/factory.go index dacdafce344..50c99dc390e 100644 --- a/storage/factory.go +++ b/storage/factory.go @@ -18,10 +18,10 @@ package storage import ( "errors" - "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" "github.com/jaegertracing/jaeger/pkg/distributedlock" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/storage/dependencystore" metricsstore "github.com/jaegertracing/jaeger/storage/metricsstore" "github.com/jaegertracing/jaeger/storage/samplingstore" diff --git a/storage/metricsstore/metrics/decorator.go b/storage/metricsstore/metrics/decorator.go index 0bb3f3b869f..3a2cca9716c 100644 --- a/storage/metricsstore/metrics/decorator.go +++ b/storage/metricsstore/metrics/decorator.go @@ -18,8 +18,7 @@ import ( "context" "time" - "github.com/uber/jaeger-lib/metrics" - + "github.com/jaegertracing/jaeger/pkg/metrics" protometrics "github.com/jaegertracing/jaeger/proto-gen/api_v2/metrics" "github.com/jaegertracing/jaeger/storage/metricsstore" ) diff --git a/storage/metricsstore/metrics/decorator_test.go b/storage/metricsstore/metrics/decorator_test.go index 39a025307ba..9cb4faaf4ab 100644 --- a/storage/metricsstore/metrics/decorator_test.go +++ b/storage/metricsstore/metrics/decorator_test.go @@ -21,8 +21,8 @@ import ( "time" "github.com/stretchr/testify/assert" - "github.com/uber/jaeger-lib/metrics/metricstest" + "github.com/jaegertracing/jaeger/internal/metricstest" protometrics "github.com/jaegertracing/jaeger/proto-gen/api_v2/metrics" "github.com/jaegertracing/jaeger/storage/metricsstore" . "github.com/jaegertracing/jaeger/storage/metricsstore/metrics" diff --git a/storage/metricsstore/mocks/Reader.go b/storage/metricsstore/mocks/Reader.go index 62faa95d36a..0814af842c0 100644 --- a/storage/metricsstore/mocks/Reader.go +++ b/storage/metricsstore/mocks/Reader.go @@ -14,7 +14,6 @@ // See the License for the specific language governing permissions and // limitations under the License. - package mocks import ( diff --git a/storage/mocks/Factory.go b/storage/mocks/Factory.go index 901f754626d..8f2c713ec1e 100644 --- a/storage/mocks/Factory.go +++ b/storage/mocks/Factory.go @@ -16,9 +16,9 @@ package mocks import ( mock "github.com/stretchr/testify/mock" - metrics "github.com/uber/jaeger-lib/metrics" zap "go.uber.org/zap" + metrics "github.com/jaegertracing/jaeger/pkg/metrics" storage "github.com/jaegertracing/jaeger/storage" dependencystore "github.com/jaegertracing/jaeger/storage/dependencystore" spanstore "github.com/jaegertracing/jaeger/storage/spanstore" diff --git a/storage/spanstore/downsampling_writer.go b/storage/spanstore/downsampling_writer.go index c00a5abcb2e..dd354e4d080 100644 --- a/storage/spanstore/downsampling_writer.go +++ b/storage/spanstore/downsampling_writer.go @@ -22,9 +22,8 @@ import ( "math/big" "sync" - "github.com/uber/jaeger-lib/metrics" - "github.com/jaegertracing/jaeger/model" + "github.com/jaegertracing/jaeger/pkg/metrics" ) const defaultHashSalt = "downsampling-default-salt" diff --git a/storage/spanstore/downsampling_writer_benchmark_test.go b/storage/spanstore/downsampling_writer_benchmark_test.go index bfc66c544be..8ca05efc1a3 100644 --- a/storage/spanstore/downsampling_writer_benchmark_test.go +++ b/storage/spanstore/downsampling_writer_benchmark_test.go @@ -21,9 +21,8 @@ import ( "math/rand" "testing" - "github.com/uber/jaeger-lib/metrics" - "github.com/jaegertracing/jaeger/model" + "github.com/jaegertracing/jaeger/pkg/metrics" ) // Benchmark result: diff --git a/storage/spanstore/metrics/decorator.go b/storage/spanstore/metrics/decorator.go index 87a258d7f59..492c37bb1ba 100644 --- a/storage/spanstore/metrics/decorator.go +++ b/storage/spanstore/metrics/decorator.go @@ -19,9 +19,8 @@ import ( "context" "time" - "github.com/uber/jaeger-lib/metrics" - "github.com/jaegertracing/jaeger/model" + "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/storage/spanstore" ) diff --git a/storage/spanstore/metrics/decorator_test.go b/storage/spanstore/metrics/decorator_test.go index a534510d774..13f61d20204 100644 --- a/storage/spanstore/metrics/decorator_test.go +++ b/storage/spanstore/metrics/decorator_test.go @@ -21,8 +21,8 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/uber/jaeger-lib/metrics/metricstest" + "github.com/jaegertracing/jaeger/internal/metricstest" "github.com/jaegertracing/jaeger/model" "github.com/jaegertracing/jaeger/storage/spanstore" . "github.com/jaegertracing/jaeger/storage/spanstore/metrics" diff --git a/storage/spanstore/metrics/write_metrics.go b/storage/spanstore/metrics/write_metrics.go index abf9ffa97d5..de56ed30e4d 100644 --- a/storage/spanstore/metrics/write_metrics.go +++ b/storage/spanstore/metrics/write_metrics.go @@ -18,7 +18,7 @@ package metrics import ( "time" - "github.com/uber/jaeger-lib/metrics" + "github.com/jaegertracing/jaeger/pkg/metrics" ) // WriteMetrics is a collection of metrics for write operations. diff --git a/storage/spanstore/metrics/write_metrics_test.go b/storage/spanstore/metrics/write_metrics_test.go index 752253b8fe1..1be8ce8e677 100644 --- a/storage/spanstore/metrics/write_metrics_test.go +++ b/storage/spanstore/metrics/write_metrics_test.go @@ -21,7 +21,8 @@ import ( "time" "github.com/stretchr/testify/assert" - "github.com/uber/jaeger-lib/metrics/metricstest" + + "github.com/jaegertracing/jaeger/internal/metricstest" ) func TestTableEmit(t *testing.T) { diff --git a/storage/spanstore/mocks/Reader.go b/storage/spanstore/mocks/Reader.go index 98a5cf130a6..5c6f43ef64e 100644 --- a/storage/spanstore/mocks/Reader.go +++ b/storage/spanstore/mocks/Reader.go @@ -14,7 +14,6 @@ // See the License for the specific language governing permissions and // limitations under the License. - package mocks import ( diff --git a/storage/spanstore/mocks/Writer.go b/storage/spanstore/mocks/Writer.go index ef9b2ba9975..dda543f8322 100644 --- a/storage/spanstore/mocks/Writer.go +++ b/storage/spanstore/mocks/Writer.go @@ -14,7 +14,6 @@ // See the License for the specific language governing permissions and // limitations under the License. - package mocks import (