@@ -177,7 +177,6 @@ func NewFileExporter(ctx context.Context, cfg *configs.FileConfig) (trace.SpanEx
177177// NewMultiExporter creates a span exporter that can export to multiple platforms simultaneously.
178178func NewMultiExporter (ctx context.Context , cfg * configs.OpenTelemetryConfig ) (trace.SpanExporter , error ) {
179179 var exporters []trace.SpanExporter
180- // 1. Explicit Exporter Types (Stdout/File)
181180 if cfg .Stdout != nil && cfg .Stdout .Enable {
182181 if exp , err := NewStdoutExporter (); err == nil {
183182 exporters = append (exporters , exp )
@@ -192,20 +191,21 @@ func NewMultiExporter(ctx context.Context, cfg *configs.OpenTelemetryConfig) (tr
192191 }
193192 }
194193
195- // 2. Platform Exporters (Can be multiple)
196- if cfg .CozeLoop != nil && cfg .CozeLoop .APIKey != "" {
197- if exp , err := NewCozeLoopExporter (ctx , cfg .CozeLoop ); err == nil {
194+ if cfg .ApmPlus != nil && cfg .ApmPlus .Endpoint != "" && cfg .ApmPlus .APIKey != "" {
195+ if exp , err := NewAPMPlusExporter (ctx , cfg .ApmPlus ); err == nil {
198196 exporters = append (exporters , exp )
199- log .Info ("Exporting spans to CozeLoop " , "endpoint" , cfg .CozeLoop .Endpoint , "service_name" , cfg .CozeLoop .ServiceName )
197+ log .Info ("Exporting spans to APMPlus " , "endpoint" , cfg .ApmPlus .Endpoint , "service_name" , cfg .ApmPlus .ServiceName )
200198 }
201199 }
202- if cfg .ApmPlus != nil && cfg .ApmPlus .APIKey != "" {
203- if exp , err := NewAPMPlusExporter (ctx , cfg .ApmPlus ); err == nil {
200+
201+ if cfg .CozeLoop != nil && cfg .CozeLoop .Endpoint != "" && cfg .CozeLoop .APIKey != "" {
202+ if exp , err := NewCozeLoopExporter (ctx , cfg .CozeLoop ); err == nil {
204203 exporters = append (exporters , exp )
205- log .Info ("Exporting spans to APMPlus " , "endpoint" , cfg .ApmPlus .Endpoint , "service_name" , cfg .ApmPlus .ServiceName )
204+ log .Info ("Exporting spans to CozeLoop " , "endpoint" , cfg .CozeLoop .Endpoint , "service_name" , cfg .CozeLoop .ServiceName )
206205 }
207206 }
208- if cfg .TLS != nil && cfg .TLS .AccessKey != "" && cfg .TLS .SecretKey != "" {
207+
208+ if cfg .TLS != nil && cfg .TLS .Endpoint != "" && cfg .TLS .AccessKey != "" && cfg .TLS .SecretKey != "" {
209209 if exp , err := NewTLSExporter (ctx , cfg .TLS ); err == nil {
210210 exporters = append (exporters , exp )
211211 log .Info ("Exporting spans to TLS" , "endpoint" , cfg .TLS .Endpoint , "service_name" , cfg .TLS .ServiceName )
@@ -214,6 +214,10 @@ func NewMultiExporter(ctx context.Context, cfg *configs.OpenTelemetryConfig) (tr
214214
215215 log .Debug ("trace data will be exported" , "exporter count" , len (exporters ))
216216
217+ if len (exporters ) == 0 {
218+ log .Info ("No exporters to export observability data" )
219+ }
220+
217221 if len (exporters ) == 1 {
218222 return exporters [0 ], nil
219223 }
@@ -263,7 +267,7 @@ func NewMetricReader(ctx context.Context, cfg *configs.OpenTelemetryConfig) ([]s
263267 }
264268 }
265269
266- if cfg .ApmPlus != nil && cfg .ApmPlus .APIKey != "" {
270+ if cfg .ApmPlus != nil && cfg .ApmPlus .Endpoint != "" && cfg . ApmPlus . APIKey != "" {
267271 if exp , err := NewAPMPlusMetricExporter (ctx , cfg .ApmPlus ); err == nil {
268272 readers = append (readers , sdkmetric .NewPeriodicReader (exp ))
269273 log .Info ("Exporting metrics to APMPlus" , "endpoint" , cfg .ApmPlus .Endpoint , "service_name" , cfg .ApmPlus .ServiceName )
0 commit comments