Convert thumbnails to service trace provider

This converts the thumbnails service to use the service trace provider.
This commit is contained in:
Daniël Franke
2023-07-31 11:13:34 +02:00
parent 3d046f6ba8
commit f4c16811a5
6 changed files with 40 additions and 40 deletions
@@ -6,27 +6,28 @@ import (
"go.opentelemetry.io/otel/trace"
thumbnailssvc "github.com/owncloud/ocis/v2/protogen/gen/ocis/services/thumbnails/v0"
thumbnailsTracing "github.com/owncloud/ocis/v2/services/thumbnails/pkg/tracing"
"go.opentelemetry.io/otel/attribute"
)
// NewTracing returns a service that instruments traces.
func NewTracing(next DecoratedService) DecoratedService {
func NewTracing(next DecoratedService, tp trace.TracerProvider) DecoratedService {
return tracing{
Decorator: Decorator{next: next},
tp: tp,
}
}
type tracing struct {
Decorator
tp trace.TracerProvider
}
// GetThumbnail implements the ThumbnailServiceHandler interface.
func (t tracing) GetThumbnail(ctx context.Context, req *thumbnailssvc.GetThumbnailRequest, rsp *thumbnailssvc.GetThumbnailResponse) error {
var span trace.Span
if thumbnailsTracing.TraceProvider != nil {
tracer := thumbnailsTracing.TraceProvider.Tracer("thumbnails")
if t.tp != nil {
tracer := t.tp.Tracer("thumbnails")
spanOpts := []trace.SpanStartOption{
trace.WithSpanKind(trace.SpanKindServer),
}