Skip to content

Commit 5076dff

Browse files
switch to autoconfig
1 parent 6053fa5 commit 5076dff

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

tw-context-starter/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ apply from: '../build.common.gradle'
77
dependencies {
88
implementation libraries.springBootAutoconfigure
99
implementation libraries.twBaseUtils
10+
implementation libraries.micrometerContextPropagation
1011
api project(":tw-context:")
1112

1213
testImplementation libraries.springBootStarterTest

tw-context-starter/src/main/java/com/transferwise/common/context/TwContextAutoConfiguration.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
@Configuration
1313
public class TwContextAutoConfiguration {
1414

15+
TwContextAutoConfiguration() {
16+
ContextRegistry.getInstance().registerThreadLocalAccessor(new TwContextThreadLocalAccessor());
17+
}
18+
1519
@Bean
1620
@ConditionalOnMissingBean
1721
public UnitOfWorkManager twContextUnitOfWorkManager(IMeterCache meterCache) {

tw-context/src/main/java/com/transferwise/common/context/TwContext.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import com.google.common.annotations.VisibleForTesting;
44
import com.google.common.util.concurrent.RateLimiter;
55
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
6-
import io.micrometer.context.ContextRegistry;
76
import java.util.HashMap;
87
import java.util.Iterator;
98
import java.util.List;
@@ -40,10 +39,6 @@ public class TwContext {
4039

4140
static final TwContext ROOT_CONTEXT = new TwContext(null, true);
4241

43-
static {
44-
ContextRegistry.getInstance().registerThreadLocalAccessor(new TwContextThreadLocalAccessor());
45-
}
46-
4742
public static TwContext current() {
4843
Optional<TwContext> twContext = contextTl.get();
4944
return twContext == null || !twContext.isPresent() ? ROOT_CONTEXT : twContext.get();

0 commit comments

Comments
 (0)