Skip to content

Commit 3958725

Browse files
Ashish AggarwalAshish Aggarwal
authored andcommitted
Add a shutdown hook for closing tracer
1 parent c60e61e commit 3958725

File tree

1 file changed

+8
-0
lines changed
  • core/src/main/java/com/expedia/www/haystack/client

1 file changed

+8
-0
lines changed

core/src/main/java/com/expedia/www/haystack/client/Tracer.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ public Tracer(String serviceName, ScopeManager scopeManager, Clock clock,
8383
this.injectFailureCounter = Counter.builder("inject").tag(new Tag("state", "exception")).register(metrics);
8484
this.extractTimer = Timer.builder("extract").register(metrics);
8585
this.extractFailureCounter = Counter.builder("extract").tag(new Tag("state", "exception")).register(metrics);
86+
87+
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
88+
try {
89+
Tracer.this.close();
90+
} catch (IOException e) {
91+
/* skip logging any error */
92+
}
93+
}));
8694
}
8795

8896
@Override

0 commit comments

Comments
 (0)