plug-sdk/pkg/plug/otlp.go
SoXX 376d7ba75d
All checks were successful
Gitea Build Check / Build (push) Successful in 57s
Gitea Build Check / Build (pull_request) Successful in 55s
feat: implemented generic algorithm
2024-10-26 21:15:02 +02:00

33 lines
781 B
Go

package plug
import (
"context"
"git.anthrove.art/Anthrove/plug-sdk/v5/pkg/telemetry"
log "github.com/sirupsen/logrus"
"go.opentelemetry.io/otel/codes"
)
func SetupOpenTelemtry(ctx context.Context, serviceName string) error {
ctx, span := tracer.Start(ctx, "SetupOpenTelemtry")
defer span.End()
err := telemetry.SetupMeterProvider(serviceName)
if err != nil {
span.RecordError(err)
span.SetStatus(codes.Error, err.Error())
log.WithContext(ctx).WithError(err).Error("Failed to setup meter provider")
return err
}
err = telemetry.SetupTraceProvider(ctx, serviceName)
if err != nil {
span.RecordError(err)
span.SetStatus(codes.Error, err.Error())
log.WithContext(ctx).WithError(err).Error("Failed to setup trace provider")
return err
}
return nil
}