Skip to content

Commit

Permalink
added LeveledMeterProvider
Browse files Browse the repository at this point in the history
Signed-off-by: shinigami-777 <[email protected]>
  • Loading branch information
shinigami-777 committed Nov 2, 2024
1 parent 1246cd3 commit 53dbac9
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 29 deletions.
6 changes: 2 additions & 4 deletions cmd/collector/app/handler/otlp_receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/jaegertracing/jaeger/cmd/collector/app/flags"
"github.com/jaegertracing/jaeger/cmd/collector/app/processor"
"github.com/jaegertracing/jaeger/pkg/config/tlscfg"
"github.com/jaegertracing/jaeger/pkg/telemetery"
"github.com/jaegertracing/jaeger/pkg/tenancy"
)

Expand Down Expand Up @@ -69,16 +68,15 @@ func startOTLPReceiver(
// TODO this could be wired into changing healthcheck.HealthCheck
logger.Info("OTLP receiver status change", zap.Stringer("status", ev.Status()))
}
settings := telemetery.InitializeNewMeterProvider()
otlpReceiverSettings := receiver.Settings{
TelemetrySettings: component.TelemetrySettings{
Logger: logger,
TracerProvider: nooptrace.NewTracerProvider(),
// TODO wire this with jaegerlib metrics?
LeveledMeterProvider: func(_ configtelemetry.Level) metric.MeterProvider {
return settings.MeterProvider
return noopmetric.NewMeterProvider()
},
MeterProvider: settings.MeterProvider,
MeterProvider: noopmetric.NewMeterProvider(),
},
}

Expand Down
6 changes: 2 additions & 4 deletions cmd/collector/app/handler/zipkin_receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (

"github.com/jaegertracing/jaeger/cmd/collector/app/flags"
"github.com/jaegertracing/jaeger/cmd/collector/app/processor"
"github.com/jaegertracing/jaeger/pkg/telemetery"
"github.com/jaegertracing/jaeger/pkg/tenancy"
)

Expand Down Expand Up @@ -63,16 +62,15 @@ func startZipkinReceiver(
CORS: options.HTTP.CORS,
// TODO keepAlive not supported?
})
settings := telemetery.InitializeNewMeterProvider()
receiverSettings := receiver.Settings{
TelemetrySettings: component.TelemetrySettings{
Logger: logger,
TracerProvider: nooptrace.NewTracerProvider(),
// TODO wire this with jaegerlib metrics?
LeveledMeterProvider: func(_ configtelemetry.Level) metric.MeterProvider {
return settings.MeterProvider
return noopmetric.NewMeterProvider()
},
MeterProvider: settings.MeterProvider,
MeterProvider: noopmetric.NewMeterProvider(),
},
}

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
10 changes: 6 additions & 4 deletions cmd/query/app/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"go.opentelemetry.io/collector/config/confighttp"
"go.opentelemetry.io/collector/config/confignet"
"go.opentelemetry.io/collector/config/configtls"
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 @@ -49,10 +50,11 @@ var testCertKeyLocation = "../../../pkg/config/tlscfg/testdata"

func initTelSet(logger *zap.Logger, tracerProvider *jtracer.JTracer, hc *healthcheck.HealthCheck) telemetery.Setting {
return telemetery.Setting{
Logger: logger,
TracerProvider: tracerProvider.OTEL,
ReportStatus: telemetery.HCAdapter(hc),
Host: componenttest.NewNopHost(),
Logger: logger,
TracerProvider: tracerProvider.OTEL,
ReportStatus: telemetery.HCAdapter(hc),
Host: componenttest.NewNopHost(),
LeveledMeterProvider: noopmetric.NewMeterProvider(),
}
}

Expand Down
20 changes: 7 additions & 13 deletions pkg/telemetery/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ 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 @@ -15,12 +16,12 @@ import (
)

type Setting struct {
Logger *zap.Logger
TracerProvider trace.TracerProvider
Metrics metrics.Factory
ReportStatus func(*componentstatus.Event)
Host component.Host
MeterProvider metric.MeterProvider
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 All @@ -42,10 +43,3 @@ func HCAdapter(hc *healthcheck.HealthCheck) func(*componentstatus.Event) {
hc.Set(hcStatus)
}
}

func InitializeNewMeterProvider() *Setting {
meterProvider := metric.NewMeterProvider()
return &Setting{
MeterProvider: meterProvider,
}
}
4 changes: 1 addition & 3 deletions plugin/storage/grpc/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (

"github.com/jaegertracing/jaeger/pkg/bearertoken"
"github.com/jaegertracing/jaeger/pkg/metrics"
"github.com/jaegertracing/jaeger/pkg/telemetery"
"github.com/jaegertracing/jaeger/pkg/tenancy"
"github.com/jaegertracing/jaeger/plugin"
"github.com/jaegertracing/jaeger/plugin/storage/grpc/shared"
Expand Down Expand Up @@ -239,8 +238,7 @@ func getTelset(logger *zap.Logger, tracerProvider trace.TracerProvider) componen
TracerProvider: tracerProvider,
// TODO needs to be joined with the metricsFactory
LeveledMeterProvider: func(_ configtelemetry.Level) metric.MeterProvider {
settings := telemetery.InitializeNewMeterProvider()
return settings.MeterProvider
return noopmetric.NewMeterProvider()
},
}
}

0 comments on commit 53dbac9

Please sign in to comment.