Skip to content

Commit

Permalink
[release/v1.33.x] Fix InstrumentedRecordInterceptor closing the trace…
Browse files Browse the repository at this point in the history
… too early (#11592)

Co-authored-by: Ben <luaworfox@gmail.com>
  • Loading branch information
opentelemetrybot and Questlog committed Jun 14, 2024
1 parent 5d310b3 commit bfc5ec3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,23 @@ private static Context getParentContext(ConsumerRecords<?, ?> records) {

@Override
public void success(ConsumerRecords<K, V> records, Consumer<K, V> consumer) {
end(records, null);
if (decorated != null) {
decorated.success(records, consumer);
try {
if (decorated != null) {
decorated.success(records, consumer);
}
} finally {
end(records, null);
}
}

@Override
public void failure(ConsumerRecords<K, V> records, Exception exception, Consumer<K, V> consumer) {
end(records, exception);
if (decorated != null) {
decorated.failure(records, exception, consumer);
try {
if (decorated != null) {
decorated.failure(records, exception, consumer);
}
} finally {
end(records, exception);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,23 @@ private static Context getParentContext(ConsumerRecord<?, ?> record) {

@Override
public void success(ConsumerRecord<K, V> record, Consumer<K, V> consumer) {
end(record, null);
if (decorated != null) {
decorated.success(record, consumer);
try {
if (decorated != null) {
decorated.success(record, consumer);
}
} finally {
end(record, null);
}
}

@Override
public void failure(ConsumerRecord<K, V> record, Exception exception, Consumer<K, V> consumer) {
end(record, exception);
if (decorated != null) {
decorated.failure(record, exception, consumer);
try {
if (decorated != null) {
decorated.failure(record, exception, consumer);
}
} finally {
end(record, exception);
}
}

Expand Down

0 comments on commit bfc5ec3

Please sign in to comment.