feat(clients): add Python, Go, and Java client libraries (BIT-14250)
Zero-dependency clients for errors.bitreport.pt following the same patterns as clients/node and clients/php: batch size 25, 5 s flush interval, 8 s HTTP timeout, fire-and-forget, env-var config. Each client ships with unit tests backed by an embedded HTTP server (no mocks), an example file, and a build manifest (pyproject.toml, go.mod, pom.xml). Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This commit is contained in:
1 parent
8bb49ce32b
commit
da57d2a444
12 files changed
+1653
No files matched your search
@@ -0,0 +1,40 @@
|
||||
import pt.bitreport.errors.ErrorReporter;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Basic usage example for the BitReport Java error reporter.
|
||||
*
|
||||
* Compile and run:
|
||||
* javac -cp path/to/bitreport-errors-1.0.0.jar BasicUsage.java
|
||||
* ERROR_REPORTING_TOKEN=your_token java -cp .:path/to/bitreport-errors-1.0.0.jar BasicUsage
|
||||
*/
|
||||
public class BasicUsage {
|
||||
public static void main(String[] args) {
|
||||
ErrorReporter.init(ErrorReporter.Config.builder()
|
||||
.token(System.getenv("ERROR_REPORTING_TOKEN"))
|
||||
.projectName("My Java App")
|
||||
.projectSlug("my-java-app")
|
||||
.build());
|
||||
|
||||
// Always flush before the JVM exits
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(ErrorReporter::flush));
|
||||
|
||||
// Report a plain message
|
||||
ErrorReporter.reportMessage("Application started", "info", null);
|
||||
|
||||
// Report a warning with context
|
||||
ErrorReporter.reportMessage("Cache miss", "warning", Map.of("cache_key", "user:42"));
|
||||
|
||||
// Report a caught exception
|
||||
try {
|
||||
int result = Integer.parseInt("not-a-number");
|
||||
} catch (NumberFormatException e) {
|
||||
ErrorReporter.reportError(e, Map.of("input", "not-a-number"));
|
||||
}
|
||||
|
||||
// Flush synchronously so the example does not exit with pending events
|
||||
ErrorReporter.flush();
|
||||
System.out.println("Events sent. Check your errors.bitreport.pt dashboard.");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user