plug-sdk/pkg/plug/otlp.go
SoXX 684d52d64c
All checks were successful
Gitea Build Check / Build (push) Successful in 58s
Gitea Build Check / Build (pull_request) Successful in 58s
feat: pumped SDK version to 4.0.0
2024-10-16 12:20:21 +02:00

33 lines
781 B
Go

package plug
import (
"context"
"git.anthrove.art/Anthrove/plug-sdk/v4/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
}