tracing: add minimal test
This commit is contained in:
		@@ -92,8 +92,6 @@ func InitTracer(ctx context.Context, cfg *TracerConfig) (TpShutdownFunc, error)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func newOLTPExporter(ctx context.Context, cfg *TracerConfig) (otelsdktrace.SpanExporter, error) {
 | 
					func newOLTPExporter(ctx context.Context, cfg *TracerConfig) (otelsdktrace.SpanExporter, error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	logger.Setup().Warn("newOLTPExporter")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	opts := []otlptracehttp.Option{otlptracehttp.WithCompression(otlptracehttp.GzipCompression)}
 | 
						opts := []otlptracehttp.Option{otlptracehttp.WithCompression(otlptracehttp.GzipCompression)}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if cfg.CertificateProvider != nil {
 | 
						if cfg.CertificateProvider != nil {
 | 
				
			||||||
@@ -102,8 +100,6 @@ func newOLTPExporter(ctx context.Context, cfg *TracerConfig) (otelsdktrace.SpanE
 | 
				
			|||||||
			GetClientCertificate: cfg.CertificateProvider,
 | 
								GetClientCertificate: cfg.CertificateProvider,
 | 
				
			||||||
			RootCAs:              cfg.RootCAs,
 | 
								RootCAs:              cfg.RootCAs,
 | 
				
			||||||
		}))
 | 
							}))
 | 
				
			||||||
	} else {
 | 
					 | 
				
			||||||
		logger.Setup().Info("no cert provider")
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if len(cfg.Endpoint) > 0 {
 | 
						if len(cfg.Endpoint) > 0 {
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										22
									
								
								tracing/tracing_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								tracing/tracing_test.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,22 @@
 | 
				
			|||||||
 | 
					package tracing
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"context"
 | 
				
			||||||
 | 
						"os"
 | 
				
			||||||
 | 
						"testing"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func TestInit(t *testing.T) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						ctx, cancel := context.WithCancel(context.Background())
 | 
				
			||||||
 | 
						defer cancel()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						os.Setenv("OTEL_EXPORTER_OTLP_ENDPOINT", "localhost")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						shutdownFn, err := InitTracer(ctx, &TracerConfig{})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							t.FailNow()
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						defer shutdownFn(ctx)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user