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 OTEL MeterProvider in Telemetery Settings #6144

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
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"
noopmetric "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 noopmetric.NewMeterProvider()
},
}
// query
querySrv := startQuery(
Expand Down
3 changes: 2 additions & 1 deletion cmd/jaeger/internal/extension/jaegerquery/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ func (s *server) Start(ctx context.Context, host component.Host) error {
ReportStatus: func(event *componentstatus.Event) {
componentstatus.ReportStatus(host, event)
},
Host: host,
Host: host,
LeveledMeterProvider: s.telset.LeveledMeterProvider,
}

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"
noopmetric "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 noopmetric.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"
noopmetric "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 noopmetric.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"
noopmetric "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 noopmetric.NewMeterProvider()
},
}
server, err := app.NewServer(context.Background(), queryService, metricsQueryService, queryOpts, tm, telset)
if err != nil {
Expand Down
15 changes: 15 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"
noopmetric "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 noopmetric.NewMeterProvider()
},
}
f := func() (*Server, error) {
return NewServer(
Expand Down Expand Up @@ -116,6 +122,9 @@ func TestNewServer_TLSConfigError(t *testing.T) {
telset := telemetery.Setting{
Logger: zap.NewNop(),
ReportStatus: telemetery.HCAdapter(healthcheck.New()),
LeveledMeterProvider: func(_ configtelemetry.Level) metric.MeterProvider {
return noopmetric.NewMeterProvider()
},
}
storageMocks := newStorageMocks()
_, err := NewServer(
Expand Down Expand Up @@ -324,6 +333,9 @@ func TestServerGRPCTLS(t *testing.T) {
telset := telemetery.Setting{
Logger: flagsSvc.Logger,
ReportStatus: telemetery.HCAdapter(flagsSvc.HC()),
LeveledMeterProvider: func(_ configtelemetry.Level) metric.MeterProvider {
return noopmetric.NewMeterProvider()
},
}
server, err := NewServer(
serverOptions,
Expand Down Expand Up @@ -373,6 +385,9 @@ func TestServerHandlesPortZero(t *testing.T) {
telset := telemetery.Setting{
Logger: flagsSvc.Logger,
ReportStatus: telemetery.HCAdapter(flagsSvc.HC()),
LeveledMeterProvider: func(_ configtelemetry.Level) metric.MeterProvider {
return noopmetric.NewMeterProvider()
},
}
server, err := NewServer(
&Options{GRPCHostPort: ":0"},
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"
noopmetric "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 noopmetric.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"
noopmetric "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 noopmetric.NewMeterProvider()
},
}
server, err := app.NewServer(opts, storageFactory, tm, telset)
require.NoError(t, err)
Expand Down
Loading