Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added LeveledMeterProvider to telemetry setting #6173

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cmd/all-in-one/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import (

"github.com/spf13/cobra"
"github.com/spf13/viper"
"go.opentelemetry.io/collector/config/configtelemetry"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/noop"
_ "go.uber.org/automaxprocs"
"go.uber.org/zap"

Expand Down Expand Up @@ -161,6 +164,9 @@ by default uses only in-memory database.`,
TracerProvider: tracer.OTEL,
Metrics: queryMetricsFactory,
ReportStatus: telemetery.HCAdapter(svc.HC()),
LeveledMeterProvider: func(_ configtelemetry.Level) metric.MeterProvider {
return noop.NewMeterProvider()
},
}
// query
querySrv := startQuery(
Expand Down
14 changes: 12 additions & 2 deletions cmd/jaeger/internal/extension/jaegerquery/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componentstatus"
"go.opentelemetry.io/collector/config/configtelemetry"
"go.opentelemetry.io/collector/extension"
"go.opentelemetry.io/collector/extension/extensioncapabilities"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/noop"

"github.com/jaegertracing/jaeger/cmd/jaeger/internal/extension/jaegerstorage"
queryApp "github.com/jaegertracing/jaeger/cmd/query/app"
Expand Down Expand Up @@ -52,7 +55,13 @@
}

func (s *server) Start(ctx context.Context, host component.Host) error {
mf := otelmetrics.NewFactory(s.telset.MeterProvider)
var meterProvider metric.MeterProvider
if s.telset.LeveledMeterProvider != nil {
meterProvider = s.telset.LeveledMeterProvider(configtelemetry.LevelNormal)
} else {
meterProvider = noop.NewMeterProvider()
}

Check warning on line 63 in cmd/jaeger/internal/extension/jaegerquery/server.go

View check run for this annotation

Codecov / codecov/patch

cmd/jaeger/internal/extension/jaegerquery/server.go#L62-L63

Added lines #L62 - L63 were not covered by tests
mf := otelmetrics.NewFactory(meterProvider)
baseFactory := mf.Namespace(metrics.NSOptions{Name: "jaeger"})
queryMetricsFactory := baseFactory.Namespace(metrics.NSOptions{Name: "query"})
f, err := jaegerstorage.GetStorageFactory(s.config.Storage.TracesPrimary, host)
Expand Down Expand Up @@ -100,7 +109,8 @@
ReportStatus: func(event *componentstatus.Event) {
componentstatus.ReportStatus(host, event)
},
Host: host,
LeveledMeterProvider: s.telset.LeveledMeterProvider,
Host: host,
}

s.server, err = queryApp.NewServer(
Expand Down
19 changes: 6 additions & 13 deletions cmd/query/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ import (
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componentstatus"
"go.opentelemetry.io/collector/config/configgrpc"
"go.opentelemetry.io/collector/config/configtelemetry"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/noop"
"go.uber.org/zap"
"google.golang.org/grpc"
"google.golang.org/grpc/health"
Expand Down Expand Up @@ -148,11 +145,9 @@ func createGRPCServer(
ctx,
telset.Host,
component.TelemetrySettings{
Logger: telset.Logger,
TracerProvider: telset.TracerProvider,
LeveledMeterProvider: func(_ configtelemetry.Level) metric.MeterProvider {
return noop.NewMeterProvider()
},
Logger: telset.Logger,
TracerProvider: telset.TracerProvider,
LeveledMeterProvider: telset.LeveledMeterProvider,
},
grpcOpts...)
}
Expand Down Expand Up @@ -219,11 +214,9 @@ func createHTTPServer(
ctx,
telset.Host,
component.TelemetrySettings{
Logger: telset.Logger,
TracerProvider: telset.TracerProvider,
LeveledMeterProvider: func(_ configtelemetry.Level) metric.MeterProvider {
return noop.NewMeterProvider()
},
Logger: telset.Logger,
TracerProvider: telset.TracerProvider,
LeveledMeterProvider: telset.LeveledMeterProvider,
},
handler,
)
Expand Down
6 changes: 6 additions & 0 deletions cmd/query/app/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ import (
"go.opentelemetry.io/collector/config/configgrpc"
"go.opentelemetry.io/collector/config/confighttp"
"go.opentelemetry.io/collector/config/confignet"
"go.opentelemetry.io/collector/config/configtelemetry"
"go.opentelemetry.io/collector/config/configtls"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/noop"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
"go.opentelemetry.io/otel/sdk/trace/tracetest"
"go.uber.org/zap"
Expand Down Expand Up @@ -53,6 +56,9 @@ func initTelSet(logger *zap.Logger, tracerProvider *jtracer.JTracer, hc *healthc
TracerProvider: tracerProvider.OTEL,
ReportStatus: telemetery.HCAdapter(hc),
Host: componenttest.NewNopHost(),
LeveledMeterProvider: func(_ configtelemetry.Level) metric.MeterProvider {
return noop.NewMeterProvider()
},
}
}

Expand Down
6 changes: 6 additions & 0 deletions cmd/query/app/token_propagation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import (
"go.opentelemetry.io/collector/config/configgrpc"
"go.opentelemetry.io/collector/config/confighttp"
"go.opentelemetry.io/collector/config/confignet"
"go.opentelemetry.io/collector/config/configtelemetry"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/noop"
"go.uber.org/zap/zaptest"

"github.com/jaegertracing/jaeger/cmd/internal/flags"
Expand Down Expand Up @@ -89,6 +92,9 @@ func runQueryService(t *testing.T, esURL string) *Server {
Logger: flagsSvc.Logger,
TracerProvider: jtracer.NoOp().OTEL,
ReportStatus: telemetery.HCAdapter(flagsSvc.HC()),
LeveledMeterProvider: func(_ configtelemetry.Level) metric.MeterProvider {
return noop.NewMeterProvider()
},
}
server, err := NewServer(context.Background(), querySvc, nil,
&QueryOptions{
Expand Down
6 changes: 6 additions & 0 deletions cmd/query/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import (

"github.com/spf13/cobra"
"github.com/spf13/viper"
"go.opentelemetry.io/collector/config/configtelemetry"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/noop"
_ "go.uber.org/automaxprocs"
"go.uber.org/zap"

Expand Down Expand Up @@ -108,6 +111,9 @@ func main() {
Logger: logger,
TracerProvider: jt.OTEL,
ReportStatus: telemetery.HCAdapter(svc.HC()),
LeveledMeterProvider: func(_ configtelemetry.Level) metric.MeterProvider {
return noop.NewMeterProvider()
},
}
server, err := app.NewServer(context.Background(), queryService, metricsQueryService, queryOpts, tm, telset)
if err != nil {
Expand Down
6 changes: 6 additions & 0 deletions cmd/remote-storage/app/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import (
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component/componentstatus"
"go.opentelemetry.io/collector/config/configtelemetry"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/noop"
"go.uber.org/zap"
"go.uber.org/zap/zaptest/observer"
"google.golang.org/grpc"
Expand Down Expand Up @@ -45,6 +48,9 @@ func TestNewServer_CreateStorageErrors(t *testing.T) {
telset := telemetery.Setting{
Logger: zap.NewNop(),
ReportStatus: func(*componentstatus.Event) {},
LeveledMeterProvider: func(_ configtelemetry.Level) metric.MeterProvider {
return noop.NewMeterProvider()
},
}
f := func() (*Server, error) {
return NewServer(
Expand Down
6 changes: 6 additions & 0 deletions cmd/remote-storage/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import (

"github.com/spf13/cobra"
"github.com/spf13/viper"
"go.opentelemetry.io/collector/config/configtelemetry"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/noop"
_ "go.uber.org/automaxprocs"
"go.uber.org/zap"

Expand Down Expand Up @@ -70,6 +73,9 @@ func main() {
telset := telemetery.Setting{
Logger: svc.Logger,
ReportStatus: telemetery.HCAdapter(svc.HC()),
LeveledMeterProvider: func(_ configtelemetry.Level) metric.MeterProvider {
return noop.NewMeterProvider()
},
}
server, err := app.NewServer(opts, storageFactory, tm, telset)
if err != nil {
Expand Down
13 changes: 8 additions & 5 deletions pkg/telemetery/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ package telemetery
import (
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componentstatus"
"go.opentelemetry.io/collector/config/configtelemetry"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/trace"
"go.uber.org/zap"

Expand All @@ -14,11 +16,12 @@ import (
)

type Setting struct {
Logger *zap.Logger
TracerProvider trace.TracerProvider
Metrics metrics.Factory
ReportStatus func(*componentstatus.Event)
Host component.Host
Logger *zap.Logger
TracerProvider trace.TracerProvider
Metrics metrics.Factory
ReportStatus func(*componentstatus.Event)
Host component.Host
LeveledMeterProvider func(_ configtelemetry.Level) metric.MeterProvider
}

func HCAdapter(hc *healthcheck.HealthCheck) func(*componentstatus.Event) {
Expand Down
6 changes: 6 additions & 0 deletions plugin/storage/integration/remote_memory_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import (
"time"

"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/config/configtelemetry"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/noop"
"go.uber.org/zap"
"go.uber.org/zap/zaptest"
"google.golang.org/grpc"
Expand Down Expand Up @@ -51,6 +54,9 @@ func StartNewRemoteMemoryStorage(t *testing.T) *RemoteMemoryStorage {
telset := telemetery.Setting{
Logger: logger,
ReportStatus: telemetery.HCAdapter(healthcheck.New()),
LeveledMeterProvider: func(_ configtelemetry.Level) metric.MeterProvider {
return noop.NewMeterProvider()
},
}
server, err := app.NewServer(opts, storageFactory, tm, telset)
require.NoError(t, err)
Expand Down
Loading