Skip to content

Commit

Permalink
Guard against null list from aws SQS lib (#9710)
Browse files Browse the repository at this point in the history
Co-authored-by: Trask Stalnaker <[email protected]>
  • Loading branch information
breedx-splk and trask committed Oct 20, 2023
1 parent 0fc1a99 commit 30e5436
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor;
import java.util.List;

/**
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
Expand Down Expand Up @@ -39,10 +40,11 @@ public static Instrumenter<SQSMessage, Void> forMessage(OpenTelemetry openTeleme

private static String spanName(SQSEvent event) {
String source = "multiple_sources";
if (!event.getRecords().isEmpty()) {
String messageSource = event.getRecords().get(0).getEventSource();
for (int i = 1; i < event.getRecords().size(); i++) {
SQSMessage message = event.getRecords().get(i);
List<SQSMessage> records = event.getRecords();
if (records != null && !records.isEmpty()) {
String messageSource = records.get(0).getEventSource();
for (int i = 1; i < records.size(); i++) {
SQSMessage message = records.get(i);
if (!message.getEventSource().equals(messageSource)) {
messageSource = null;
break;
Expand Down

0 comments on commit 30e5436

Please sign in to comment.