diff --git a/exegroup/group_test.go b/exegroup/group_test.go index c99b45b..b6a5d04 100644 --- a/exegroup/group_test.go +++ b/exegroup/group_test.go @@ -2,8 +2,9 @@ package exegroup_test import ( "context" - "git.blauwelle.com/go/crate/exegroup" "log" + + "git.blauwelle.com/go/crate/exegroup" ) func Example_defaultGroup() { diff --git a/uptracehelper/helper.go b/uptracehelper/helper.go index 864fbfa..31706f3 100644 --- a/uptracehelper/helper.go +++ b/uptracehelper/helper.go @@ -2,6 +2,7 @@ package uptracehelper import ( "context" + "github.com/uptrace/uptrace-go/uptrace" ) @@ -11,12 +12,7 @@ type Config struct { DeploymentEnvironment string } -// InitTracer 初始化并等待 uptrace -// 配合 [git.blauwelle.com/go/crate/exegroup] 使用 -// env -// - UPTRACE_DISABLED 存在就不再初始化 -// - UPTRACE_DSN 服务端地址 -func InitTracer(cfg Config) (func(ctx context.Context) error, func(ctx context.Context)) { +func Setup(cfg Config) { opts := []uptrace.Option{ uptrace.WithServiceName(cfg.ServiceName), uptrace.WithServiceVersion(cfg.ServiceVersion), @@ -25,7 +21,16 @@ func InitTracer(cfg Config) (func(ctx context.Context) error, func(ctx context.C opts = append(opts, uptrace.WithDeploymentEnvironment(cfg.DeploymentEnvironment)) } uptrace.ConfigureOpentelemetry(opts...) - shutdownErr := make(chan error) +} + +// GoStop 初始化并等待 uptrace +// 配合 [git.blauwelle.com/go/crate/exegroup] 使用 +// env +// - UPTRACE_DISABLED 存在就不再初始化 +// - UPTRACE_DSN 服务端地址 +func GoStop(cfg Config) (func(ctx context.Context) error, func(ctx context.Context)) { + Setup(cfg) + shutdownErr := make(chan error, 1) goFunc := func(context.Context) error { return <-shutdownErr }