From a49a164a2ab22d4772d2f43ae2a73880ae095599 Mon Sep 17 00:00:00 2001 From: Yuri Shkuro Date: Mon, 4 Sep 2023 11:27:06 -0400 Subject: [PATCH] [chore] Remove direct dependency on jaeger-lib (#4721) ## Which problem is this PR solving? - Part of #3381 ## Description of the changes - Remove internal unused package `jlibadapter` - Remove unnecessary dependency on jaeger-lib in the tests ## How was this change tested? - Unit tests Signed-off-by: Yuri Shkuro --- go.mod | 2 +- internal/metrics/expvar/metrics_test.go | 2 +- internal/metrics/jlibadapter/adapter.go | 80 -------------------- internal/metrics/jlibadapter/adapter_test.go | 32 -------- 4 files changed, 2 insertions(+), 114 deletions(-) delete mode 100644 internal/metrics/jlibadapter/adapter.go delete mode 100644 internal/metrics/jlibadapter/adapter_test.go diff --git a/go.mod b/go.mod index eee12b1b658..219e3c6a73e 100644 --- a/go.mod +++ b/go.mod @@ -42,7 +42,6 @@ require ( github.com/spf13/viper v1.16.0 github.com/stretchr/testify v1.8.4 github.com/uber/jaeger-client-go v2.30.0+incompatible - github.com/uber/jaeger-lib v2.4.1+incompatible github.com/xdg-go/scram v1.1.2 go.opentelemetry.io/collector/component v0.84.0 go.opentelemetry.io/collector/config/configgrpc v0.84.0 @@ -151,6 +150,7 @@ require ( github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/stretchr/objx v0.5.0 // indirect github.com/subosito/gotenv v1.4.2 // indirect + github.com/uber/jaeger-lib v2.4.1+incompatible // indirect github.com/xdg-go/pbkdf2 v1.0.0 // indirect github.com/xdg-go/stringprep v1.0.4 // indirect go.mongodb.org/mongo-driver v1.11.6 // indirect diff --git a/internal/metrics/expvar/metrics_test.go b/internal/metrics/expvar/metrics_test.go index 9beb9c31ed6..ca98480f3b5 100644 --- a/internal/metrics/expvar/metrics_test.go +++ b/internal/metrics/expvar/metrics_test.go @@ -20,9 +20,9 @@ import ( "github.com/go-kit/kit/metrics/generic" "github.com/stretchr/testify/assert" - "github.com/uber/jaeger-lib/metrics" "github.com/jaegertracing/jaeger/internal/metrics/expvar" + "github.com/jaegertracing/jaeger/pkg/metrics" ) func TestCounter(t *testing.T) { diff --git a/internal/metrics/jlibadapter/adapter.go b/internal/metrics/jlibadapter/adapter.go deleted file mode 100644 index 026e0edacd2..00000000000 --- a/internal/metrics/jlibadapter/adapter.go +++ /dev/null @@ -1,80 +0,0 @@ -// 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 jlibadapter - -import ( - jlibmetrics "github.com/uber/jaeger-lib/metrics" - - "github.com/jaegertracing/jaeger/pkg/metrics" -) - -// adapter is temporary type used to bridge metrics API in this package -// with that of jaeger-lib. -type adapter struct { - f metrics.Factory -} - -var _ jlibmetrics.Factory = (*adapter)(nil) - -// NewAdapter wraps internal metrics.Factory to look like jaeger-lib version. -func NewAdapter(f metrics.Factory) jlibmetrics.Factory { - return &adapter{f: f} -} - -// Counter creates a Counter. -func (a *adapter) Counter(opts jlibmetrics.Options) jlibmetrics.Counter { - return a.f.Counter(metrics.Options{ - Name: opts.Name, - Tags: opts.Tags, - Help: opts.Help, - }) -} - -// Timer creates a Timer. -func (a *adapter) Timer(opts jlibmetrics.TimerOptions) jlibmetrics.Timer { - return a.f.Timer(metrics.TimerOptions{ - Name: opts.Name, - Tags: opts.Tags, - Help: opts.Help, - Buckets: opts.Buckets, - }) -} - -// Gauge creates a Gauge. -func (a *adapter) Gauge(opts jlibmetrics.Options) jlibmetrics.Gauge { - return a.f.Gauge(metrics.Options{ - Name: opts.Name, - Tags: opts.Tags, - Help: opts.Help, - }) -} - -// Histogram creates a Histogram. -func (a *adapter) Histogram(opts jlibmetrics.HistogramOptions) jlibmetrics.Histogram { - return a.f.Histogram(metrics.HistogramOptions{ - Name: opts.Name, - Tags: opts.Tags, - Help: opts.Help, - Buckets: opts.Buckets, - }) -} - -// Namespace creates a Namespace. -func (a *adapter) Namespace(opts jlibmetrics.NSOptions) jlibmetrics.Factory { - return &adapter{f: a.f.Namespace(metrics.NSOptions{ - Name: opts.Name, - Tags: opts.Tags, - })} -} diff --git a/internal/metrics/jlibadapter/adapter_test.go b/internal/metrics/jlibadapter/adapter_test.go deleted file mode 100644 index 55488c91894..00000000000 --- a/internal/metrics/jlibadapter/adapter_test.go +++ /dev/null @@ -1,32 +0,0 @@ -// 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 jlibadapter - -import ( - "testing" - - jlibmetrics "github.com/uber/jaeger-lib/metrics" - - "github.com/jaegertracing/jaeger/pkg/metrics" -) - -func TestAdapter(t *testing.T) { - f := NewAdapter(metrics.NullFactory) - f.Counter(jlibmetrics.Options{}) - f.Timer(jlibmetrics.TimerOptions{}) - f.Gauge(jlibmetrics.Options{}) - f.Histogram(jlibmetrics.HistogramOptions{}) - f.Namespace(jlibmetrics.NSOptions{}) -}