|
3 | 3 | import com.datadoghq.trace.DDBaseSpan; |
4 | 4 | import com.datadoghq.trace.Service; |
5 | 5 | import com.google.auto.service.AutoService; |
| 6 | +import com.google.common.util.concurrent.ThreadFactoryBuilder; |
6 | 7 | import java.util.List; |
7 | 8 | import java.util.Map; |
8 | 9 | import java.util.concurrent.Callable; |
9 | 10 | import java.util.concurrent.ExecutorService; |
10 | 11 | import java.util.concurrent.Executors; |
11 | 12 | import java.util.concurrent.Future; |
12 | 13 | import java.util.concurrent.ScheduledExecutorService; |
| 14 | +import java.util.concurrent.ThreadFactory; |
13 | 15 | import java.util.concurrent.TimeUnit; |
14 | 16 | import java.util.concurrent.TimeoutException; |
15 | 17 | import lombok.extern.slf4j.Slf4j; |
@@ -40,12 +42,16 @@ public class DDAgentWriter implements Writer { |
40 | 42 | /** Flush interval for the API in seconds */ |
41 | 43 | static final long FLUSH_TIME_SECONDS = 1; |
42 | 44 |
|
| 45 | + private final ThreadFactory agentWriterThreadFactory = |
| 46 | + new ThreadFactoryBuilder().setNameFormat("dd-agent-writer-%d").setDaemon(true).build(); |
| 47 | + |
43 | 48 | /** Scheduled thread pool, acting like a cron */ |
44 | | - private final ScheduledExecutorService scheduledExecutor = Executors.newScheduledThreadPool(1); |
45 | | - // FIXME: Properly name these threads to better identify them as ours. |
| 49 | + private final ScheduledExecutorService scheduledExecutor = |
| 50 | + Executors.newScheduledThreadPool(1, agentWriterThreadFactory); |
46 | 51 |
|
47 | 52 | /** Effective thread pool, where real logic is done */ |
48 | | - private final ExecutorService executor = Executors.newSingleThreadExecutor(); |
| 53 | + private final ExecutorService executor = |
| 54 | + Executors.newSingleThreadExecutor(agentWriterThreadFactory); |
49 | 55 |
|
50 | 56 | /** The DD agent api */ |
51 | 57 | private final DDApi api; |
|
0 commit comments