Add tracing to eventhistory service.

This adds tracing to the event history service.
This commit is contained in:
Daniël Franke
2023-07-26 12:17:22 +02:00
parent 1658084812
commit d00f5a9da5
5 changed files with 50 additions and 20 deletions
+19 -10
View File
@@ -9,6 +9,7 @@ import (
"github.com/owncloud/ocis/v2/services/eventhistory/pkg/metrics"
"github.com/urfave/cli/v2"
"go-micro.dev/v4/store"
"go.opentelemetry.io/otel/trace"
)
// Option defines a single option function.
@@ -16,16 +17,17 @@ type Option func(o *Options)
// Options defines the available options for this package.
type Options struct {
Name string
Address string
Logger log.Logger
Context context.Context
Config *config.Config
Metrics *metrics.Metrics
Namespace string
Flags []cli.Flag
Persistence store.Store
Consumer events.Consumer
Name string
Address string
Logger log.Logger
Context context.Context
Config *config.Config
Metrics *metrics.Metrics
Namespace string
Flags []cli.Flag
Persistence store.Store
Consumer events.Consumer
TraceProvider trace.TracerProvider
}
// newOptions initializes the available default options.
@@ -108,3 +110,10 @@ func Consumer(consumer events.Consumer) Option {
o.Consumer = consumer
}
}
// TraceProvider provides a function to configure the trace provider
func TraceProvider(traceProvider trace.TracerProvider) Option {
return func(o *Options) {
o.TraceProvider = traceProvider
}
}
@@ -25,6 +25,7 @@ func NewService(opts ...Option) grpc.Service {
grpc.Context(options.Context),
grpc.Flags(options.Flags...),
grpc.Version(version.GetString()),
grpc.TraceProvider(options.TraceProvider),
)
if err != nil {
options.Logger.Fatal().Err(err).Msg("Error creating event history service")