@@ -55,7 +55,8 @@ type sumologicexporter struct {
55
55
stickySessionCookieLock sync.RWMutex
56
56
stickySessionCookie string
57
57
58
- id component.ID
58
+ id component.ID
59
+ sender * sender
59
60
}
60
61
61
62
func initExporter (cfg * Config , createSettings exporter.Settings ) * sumologicexporter {
@@ -229,6 +230,21 @@ func (se *sumologicexporter) configure(ctx context.Context) error {
229
230
}
230
231
231
232
se .setHTTPClient (client )
233
+
234
+ logsURL , metricsURL , tracesURL := se .getDataURLs ()
235
+ se .sender = newSender (
236
+ se .logger ,
237
+ se .config ,
238
+ se .getHTTPClient (),
239
+ se .prometheusFormatter ,
240
+ metricsURL ,
241
+ logsURL ,
242
+ tracesURL ,
243
+ se .StickySessionCookie ,
244
+ se .SetStickySessionCookie ,
245
+ se .id ,
246
+ )
247
+
232
248
return nil
233
249
}
234
250
@@ -265,23 +281,9 @@ func (se *sumologicexporter) shutdown(context.Context) error {
265
281
// It returns the number of unsent logs and an error which contains a list of dropped records
266
282
// so they can be handled by OTC retry mechanism
267
283
func (se * sumologicexporter ) pushLogsData (ctx context.Context , ld plog.Logs ) error {
268
- logsURL , metricsURL , tracesURL := se .getDataURLs ()
269
- sdr := newSender (
270
- se .logger ,
271
- se .config ,
272
- se .getHTTPClient (),
273
- se .prometheusFormatter ,
274
- metricsURL ,
275
- logsURL ,
276
- tracesURL ,
277
- se .StickySessionCookie ,
278
- se .SetStickySessionCookie ,
279
- se .id ,
280
- )
281
-
282
284
// Follow different execution path for OTLP format
283
- if sdr .config .LogFormat == OTLPLogFormat {
284
- if err := sdr .sendOTLPLogs (ctx , ld ); err != nil {
285
+ if se . sender .config .LogFormat == OTLPLogFormat {
286
+ if err := se . sender .sendOTLPLogs (ctx , ld ); err != nil {
285
287
se .handleUnauthorizedErrors (ctx , err )
286
288
return consumererror .NewLogs (err , ld )
287
289
}
@@ -304,7 +306,7 @@ func (se *sumologicexporter) pushLogsData(ctx context.Context, ld plog.Logs) err
304
306
305
307
currentMetadata := newFields (rl .Resource ().Attributes ())
306
308
307
- if droppedRecords , err := sdr .sendNonOTLPLogs (ctx , rl , currentMetadata ); err != nil {
309
+ if droppedRecords , err := se . sender .sendNonOTLPLogs (ctx , rl , currentMetadata ); err != nil {
308
310
dropped = append (dropped , droppedResourceRecords {
309
311
resource : rl .Resource (),
310
312
records : droppedRecords ,
@@ -342,29 +344,15 @@ func (se *sumologicexporter) pushLogsData(ctx context.Context, ld plog.Logs) err
342
344
// it returns number of unsent metrics and error which contains list of dropped records
343
345
// so they can be handle by the OTC retry mechanism
344
346
func (se * sumologicexporter ) pushMetricsData (ctx context.Context , md pmetric.Metrics ) error {
345
- logsURL , metricsURL , tracesURL := se .getDataURLs ()
346
- sdr := newSender (
347
- se .logger ,
348
- se .config ,
349
- se .getHTTPClient (),
350
- se .prometheusFormatter ,
351
- metricsURL ,
352
- logsURL ,
353
- tracesURL ,
354
- se .StickySessionCookie ,
355
- se .SetStickySessionCookie ,
356
- se .id ,
357
- )
358
-
359
347
var droppedMetrics pmetric.Metrics
360
348
var errs []error
361
- if sdr .config .MetricFormat == OTLPMetricFormat {
362
- if err := sdr .sendOTLPMetrics (ctx , md ); err != nil {
349
+ if se . sender .config .MetricFormat == OTLPMetricFormat {
350
+ if err := se . sender .sendOTLPMetrics (ctx , md ); err != nil {
363
351
droppedMetrics = md
364
352
errs = []error {err }
365
353
}
366
354
} else {
367
- droppedMetrics , errs = sdr .sendNonOTLPMetrics (ctx , md )
355
+ droppedMetrics , errs = se . sender .sendNonOTLPMetrics (ctx , md )
368
356
}
369
357
370
358
if len (errs ) > 0 {
@@ -394,21 +382,7 @@ func (se *sumologicexporter) handleUnauthorizedErrors(ctx context.Context, errs
394
382
}
395
383
396
384
func (se * sumologicexporter ) pushTracesData (ctx context.Context , td ptrace.Traces ) error {
397
- logsURL , metricsURL , tracesURL := se .getDataURLs ()
398
- sdr := newSender (
399
- se .logger ,
400
- se .config ,
401
- se .getHTTPClient (),
402
- se .prometheusFormatter ,
403
- metricsURL ,
404
- logsURL ,
405
- tracesURL ,
406
- se .StickySessionCookie ,
407
- se .SetStickySessionCookie ,
408
- se .id ,
409
- )
410
-
411
- err := sdr .sendTraces (ctx , td )
385
+ err := se .sender .sendTraces (ctx , td )
412
386
se .handleUnauthorizedErrors (ctx , err )
413
387
return err
414
388
}
0 commit comments