Add helper class to capture context using ScheduledExecutorService#6712
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6712 +/- ##
============================================
- Coverage 90.09% 90.01% -0.08%
- Complexity 6390 6482 +92
============================================
Files 711 719 +8
Lines 19333 19585 +252
Branches 1891 1931 +40
============================================
+ Hits 17418 17630 +212
- Misses 1335 1355 +20
- Partials 580 600 +20 ☔ View full report in Codecov by Sentry. |
jkwatson
left a comment
There was a problem hiding this comment.
This is a good idea. This PR needs some more testing, as there are bunch of uncovered methods in the implementation.
Signed-off-by: Adriano Machado <60320+ammachado@users.noreply.github.com>
b6c022c to
e5d7cc4
Compare
context/src/main/java/io/opentelemetry/context/CurrentContextScheduledExecutorService.java
Outdated
Show resolved
Hide resolved
context/src/main/java/io/opentelemetry/context/ForwardingScheduledExecutorService.java
Outdated
Show resolved
Hide resolved
| private final ScheduledExecutorService delegate; | ||
|
|
||
| CurrentContextScheduledExecutorService(ScheduledExecutorService delegate) { | ||
| super(delegate); | ||
| this.delegate = delegate; | ||
| } |
There was a problem hiding this comment.
| private final ScheduledExecutorService delegate; | |
| CurrentContextScheduledExecutorService(ScheduledExecutorService delegate) { | |
| super(delegate); | |
| this.delegate = delegate; | |
| } | |
| CurrentContextScheduledExecutorService(ScheduledExecutorService delegate) { | |
| super(delegate); | |
| } |
|
|
||
| @Override | ||
| public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) { | ||
| return delegate.schedule(Context.current().wrap(command), delay, unit); |
There was a problem hiding this comment.
| return delegate.schedule(Context.current().wrap(command), delay, unit); | |
| return ((ScheduledExecutorService) delegate()) | |
| .schedule(Context.current().wrap(command), delay, unit); |
There was a problem hiding this comment.
I think I prefer just keeping a local copy of the delegate rather than having to make this cast everywhere.
|
|
||
| @Override | ||
| public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) { | ||
| return delegate.schedule(Context.current().wrap(callable), delay, unit); |
There was a problem hiding this comment.
| return delegate.schedule(Context.current().wrap(callable), delay, unit); | |
| return ((ScheduledExecutorService) delegate()) | |
| .schedule(Context.current().wrap(callable), delay, unit); |
| @Override | ||
| public ScheduledFuture<?> scheduleAtFixedRate( | ||
| Runnable command, long initialDelay, long period, TimeUnit unit) { | ||
| return delegate.scheduleAtFixedRate(command, initialDelay, period, unit); |
There was a problem hiding this comment.
| return delegate.scheduleAtFixedRate(command, initialDelay, period, unit); | |
| return ((ScheduledExecutorService) delegate()) | |
| .scheduleAtFixedRate(command, initialDelay, period, unit); |
| @Override | ||
| public ScheduledFuture<?> scheduleWithFixedDelay( | ||
| Runnable command, long initialDelay, long delay, TimeUnit unit) { | ||
| return delegate.scheduleWithFixedDelay(command, initialDelay, delay, unit); |
There was a problem hiding this comment.
| return delegate.scheduleWithFixedDelay(command, initialDelay, delay, unit); | |
| return ((ScheduledExecutorService) delegate()) | |
| .scheduleWithFixedDelay(command, initialDelay, delay, unit); |
No description provided.