Skip to content

Commit

Permalink
fixed the traffic label is lost in the HikariDataSource scenario
Browse files Browse the repository at this point in the history
Signed-off-by: chengyouling <[email protected]>
  • Loading branch information
chengyouling committed Jan 2, 2025
1 parent 18c63df commit 284bf61
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public abstract class AbstractThreadWrapper<T> {

private final boolean cannotTransmit;

private final long threadId;

/**
* Constructor
*
Expand All @@ -66,6 +68,7 @@ public AbstractThreadWrapper(Runnable runnable, Callable<T> callable, RequestTag
this.requestData = requestData;
}
this.cannotTransmit = cannotTransmit;
this.threadId = Thread.currentThread().getId();
}

/**
Expand Down Expand Up @@ -117,6 +120,9 @@ private void before(Object obj) {
}

private void after() {
if (threadId == Thread.currentThread().getId()) {
return;
}
ThreadLocalUtils.removeRequestTag();
ThreadLocalUtils.removeRequestData();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public abstract class AbstractThreadWrapper<T> {

private final boolean cannotTransmit;

private final long threadId;

/**
* constructor
*
Expand All @@ -73,6 +75,7 @@ public AbstractThreadWrapper(Runnable runnable, Callable<T> callable, TrafficMes
}
this.cannotTransmit = cannotTransmit;
this.executorName = executorName;
this.threadId = Thread.currentThread().getId();
}

/**
Expand Down Expand Up @@ -133,6 +136,9 @@ protected void before(Object obj) {
* Post method executed by thread object
*/
protected void after() {
if (threadId == Thread.currentThread().getId()) {
return;
}
TrafficUtils.removeTrafficTag();
TrafficUtils.removeTrafficData();
}
Expand Down

0 comments on commit 284bf61

Please sign in to comment.