-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
1,033 additions
and
54 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
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
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
31 changes: 31 additions & 0 deletions
31
dd-java-agent/agent-crashtracking/src/main/java/com/datadog/crashtracking/OOMENotifier.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,31 @@ | ||
package com.datadog.crashtracking; | ||
|
||
import static datadog.communication.monitor.DDAgentStatsDClientManager.statsDClientManager; | ||
|
||
import datadog.communication.monitor.DDAgentStatsDClient; | ||
import de.thetaphi.forbiddenapis.SuppressForbidden; | ||
import java.util.concurrent.locks.LockSupport; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public final class OOMENotifier { | ||
private static final Logger log = LoggerFactory.getLogger(OOMENotifier.class); | ||
|
||
// This method is called via CLI so we don't need to be paranoid about the forbiddend APIs | ||
@SuppressForbidden | ||
public static void sendOomeEvent(String taglist) { | ||
try (DDAgentStatsDClient client = | ||
(DDAgentStatsDClient) | ||
statsDClientManager().statsDClient(null, null, null, null, null, false)) { | ||
String[] tags = taglist.split(","); | ||
client.recordEvent( | ||
"error", | ||
"java", | ||
"OutOfMemoryError", | ||
"Java process encountered out of memory error", | ||
tags); | ||
log.info("OOME event sent"); | ||
LockSupport.parkNanos(2_000_000_000L); // wait 2s to allow statsd client flushing the event | ||
} | ||
} | ||
} |
Oops, something went wrong.