-
Notifications
You must be signed in to change notification settings - Fork 850
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add helper class to capture context using ScheduledExecutorService (#…
…6712) Signed-off-by: Adriano Machado <[email protected]>
- Loading branch information
Showing
6 changed files
with
383 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# Gradle | ||
build | ||
.gradle | ||
.kotlin | ||
local.properties | ||
out/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
context/src/main/java/io/opentelemetry/context/CurrentContextScheduledExecutorService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.context; | ||
|
||
import java.util.concurrent.Callable; | ||
import java.util.concurrent.ScheduledExecutorService; | ||
import java.util.concurrent.ScheduledFuture; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
final class CurrentContextScheduledExecutorService extends CurrentContextExecutorService | ||
implements ScheduledExecutorService { | ||
|
||
private final ScheduledExecutorService delegate; | ||
|
||
CurrentContextScheduledExecutorService(ScheduledExecutorService delegate) { | ||
super(delegate); | ||
this.delegate = delegate; | ||
} | ||
|
||
@Override | ||
public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) { | ||
return delegate.schedule(Context.current().wrap(command), delay, unit); | ||
} | ||
|
||
@Override | ||
public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) { | ||
return 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); | ||
} | ||
|
||
@Override | ||
public ScheduledFuture<?> scheduleWithFixedDelay( | ||
Runnable command, long initialDelay, long delay, TimeUnit unit) { | ||
return delegate.scheduleWithFixedDelay(command, initialDelay, delay, unit); | ||
} | ||
} |
Oops, something went wrong.