11
11
import io .lumigo .core .utils .AwsUtils ;
12
12
import io .lumigo .core .utils .JsonUtils ;
13
13
import io .lumigo .core .utils .StringUtils ;
14
- import io .lumigo .models .HttpSpan ;
15
- import io .lumigo .models .KafkaSpan ;
16
- import io .lumigo .models .KafkaSpanFactory ;
17
- import io .lumigo .models .Span ;
14
+ import io .lumigo .models .*;
18
15
import java .io .*;
19
16
import java .util .*;
20
17
import java .util .concurrent .Callable ;
18
+ import lombok .Getter ;
21
19
import org .apache .http .Header ;
22
20
import org .apache .http .HttpEntity ;
23
21
import org .apache .http .HttpResponse ;
@@ -54,8 +52,8 @@ public class SpansContainer {
54
52
private Long rttDuration ;
55
53
private Span endFunctionSpan ;
56
54
private Reporter reporter ;
57
- private List < HttpSpan > httpSpans = new LinkedList <>();
58
- private List <KafkaSpan > kafkaSpans = new LinkedList <>();
55
+
56
+ @ Getter private List <BaseSpan > spans = new LinkedList <>();
59
57
60
58
private static final SpansContainer ourInstance = new SpansContainer ();
61
59
@@ -71,8 +69,7 @@ public void clear() {
71
69
rttDuration = null ;
72
70
endFunctionSpan = null ;
73
71
reporter = null ;
74
- httpSpans = new LinkedList <>();
75
- kafkaSpans = new LinkedList <>();
72
+ spans = new LinkedList <>();
76
73
}
77
74
78
75
private SpansContainer () {}
@@ -230,19 +227,14 @@ public Span getStartFunctionSpan() {
230
227
public List <Object > getAllCollectedSpans () {
231
228
List <Object > spans = new LinkedList <>();
232
229
spans .add (endFunctionSpan );
233
- spans .addAll (httpSpans );
234
- spans .addAll (kafkaSpans );
230
+ spans .addAll (this .spans );
235
231
return spans ;
236
232
}
237
233
238
234
public Span getEndSpan () {
239
235
return endFunctionSpan ;
240
236
}
241
237
242
- public List <HttpSpan > getHttpSpans () {
243
- return httpSpans ;
244
- }
245
-
246
238
private String getStackTrace (Throwable throwable ) {
247
239
StringWriter sw = new StringWriter ();
248
240
PrintWriter pw = new PrintWriter (sw , true );
@@ -317,7 +309,7 @@ public void addHttpSpan(Long startTime, HttpUriRequest request, HttpResponse res
317
309
response .getStatusLine ().getStatusCode ())
318
310
.build ())
319
311
.build ());
320
- httpSpans .add (httpSpan );
312
+ this . spans .add (httpSpan );
321
313
}
322
314
323
315
public void addHttpSpan (Long startTime , Request <?> request , Response <?> response ) {
@@ -376,7 +368,7 @@ public void addHttpSpan(Long startTime, Request<?> request, Response<?> response
376
368
.build ());
377
369
AwsSdkV1ParserFactory .getParser (request .getServiceName ())
378
370
.safeParse (httpSpan , request , response );
379
- httpSpans .add (httpSpan );
371
+ this . spans .add (httpSpan );
380
372
}
381
373
382
374
public void addHttpSpan (
@@ -445,7 +437,7 @@ public void addHttpSpan(
445
437
executionAttributes .getAttribute (SdkExecutionAttribute .SERVICE_NAME ))
446
438
.safeParse (httpSpan , context );
447
439
448
- httpSpans .add (httpSpan );
440
+ this . spans .add (httpSpan );
449
441
}
450
442
451
443
public <K , V > void addKafkaProduceSpan (
@@ -456,7 +448,7 @@ public <K, V> void addKafkaProduceSpan(
456
448
ProducerRecord <K , V > record ,
457
449
RecordMetadata recordMetadata ,
458
450
Exception exception ) {
459
- this .kafkaSpans .add (
451
+ this .spans .add (
460
452
KafkaSpanFactory .createProduce (
461
453
this .baseSpan ,
462
454
startTime ,
@@ -473,7 +465,7 @@ public void addKafkaConsumeSpan(
473
465
KafkaConsumer <?, ?> consumer ,
474
466
ConsumerMetadata consumerMetadata ,
475
467
ConsumerRecords <?, ?> consumerRecords ) {
476
- this .kafkaSpans .add (
468
+ this .spans .add (
477
469
KafkaSpanFactory .createConsume (
478
470
this .baseSpan , startTime , consumer , consumerMetadata , consumerRecords ));
479
471
}
0 commit comments