| 
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -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
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
			
			 | 
			 | 
			
				
 
 |