Verify JRE Java SDK events
このページはまだあなたの言語に翻訳されていません。 現在取り組んでいますので、後でもう一度確認してください。
An event moves through four stages between your logEvent() call and Amplitude's servers. Verify each stage in order. The first stage where the event looks wrong is where the problem is.
| Stage | Question | Where to look |
|---|---|---|
| Captured | Did the SDK accept the call? | An inspection middleware |
| Transformed | What did middleware add, change, or drop? | The same middleware, added last |
| Sent | Did the request leave the JVM, and with what? | Debug logs, or an intercepting HTTPS proxy |
| Received | Did Amplitude accept and store the event? | The upload callback, then User Lookup in Amplitude |
For problems common to every Amplitude SDK, go to SDK troubleshooting and debugging. If behavior changed after an SDK upgrade, check the Java SDK changelog.
Turn on debug logging
Set the log level to DEBUG while you verify.
Amplitude client = Amplitude.getInstance();
client.init("AMPLITUDE_API_KEY");
client.setLogMode(AmplitudeLog.LogMode.DEBUG);
client.logEvent(new Event("Sign Up Completed", "user-12345"));
The SDK logs only when it uploads or retries events. It prints nothing when you call logEvent(). Each message has the form <tag>: <message>. DEBUG and WARN messages go to standard output, and ERROR messages go to standard error.
| Tag | Level | When |
|---|---|---|
SEND | DEBUG | After an upload, with the number of events in it: SEND: Events count 1. |
RETRY | DEBUG | After a retry, with the number of events in it. At ERROR, a retry thread failed. |
RESPONSE | DEBUG | After SEND or RETRY, with the response as JSON. |
DROP EVENTS | WARN | The retry buffer held 16,000 events, so the SDK dropped events instead of retrying them. |
Flush Thread Error | ERROR | An upload failed with an exception, followed by its stack trace. |
Error event payload | ERROR | After Flush Thread Error, with the events of the failed upload. |
A successful upload logs this:
SEND: Events count 1
RESPONSE: {
"code": 200,
"successBody": {
"serverUploadTime": 1794340064240,
"payloadSizeBytes": 412,
"eventsIngested": 1
},
"status": "SUCCESS"
}
The SDK doesn't log the API key. Error event payload lines contain event data, so return the level to ERROR before you deploy.
Check what the SDK captured
The SDK has no log for logEvent(). To see each event as logEvent() receives it, add a middleware that prints it and passes it on:
Amplitude client = Amplitude.getInstance();
client.init("AMPLITUDE_API_KEY");
client.addEventMiddleware((payload, next) -> {
System.out.println("Amplitude event: " + payload.event);
next.run(payload);
});
Event event = new Event("Sign Up Completed", "user-12345");
event.addEventProperty("plan", "starter");
client.logEvent(event);
The middleware prints the event as JSON, with the same fields the SDK uploads:
{
"event_type": "Sign Up Completed",
"user_id": "user-12345",
"device_id": null,
"event_properties": { "plan": "starter" },
"user_properties": {},
"groups": {},
"group_properties": {},
"session_id": -1,
"event_id": 0,
"location_lat": 0,
"location_lng": 0,
"library": "amplitude-java/1.13.1"
}
Check the output for these problems:
| What you see | What it means |
|---|---|
| No line for the event | The call never ran, or a middleware added earlier didn't call next and dropped the event. |
user_id and device_id both null | Not possible: the Event constructor throws first. If either ID is a placeholder, such as an empty string, Amplitude rejects the event or attributes it wrongly. |
session_id is -1 | Expected. The SDK doesn't track sessions. Go to Attach a session ID. |
location_lat and location_lng are 0 | Expected. The SDK sends both fields on every event, with 0 when you don't set them. |
Check how middleware transformed the event
Middleware runs in the order you added it. To see the event after your other middleware changed it, add the inspection middleware last. A middleware that doesn't call next.run(payload) drops the event: it never reaches the queue, and no callback runs for it.
The SDK adds no fields in middleware. Before the first middleware runs, it adds the instance's Plan and IngestionMetadata to events that have none. It adds library when it builds the upload.
Check what the SDK sent
A server process has no Network tab. The upload body is a JSON object with api_key, events (each event's toJsonObject()), and options when you set Options. The SDK doesn't compress it.
- Count: at
DEBUGlevel,SEND: Events count Nconfirms that an upload ran and how many events it held. - Content: the inspection middleware prints what each event contributes to the body.
- Raw request: the SDK sends only over HTTPS, so a plain local HTTP server can't receive it. Run an intercepting HTTPS proxy, point the SDK at it with
setProxy(), and add the proxy's certificate to the JVM's trust store.
If no SEND line appears, the upload didn't run. The usual cause is a program that ends before the next scheduled upload. Go to Flush and shut down.
Check what Amplitude received
Read the upload result
The SDK reports the result for each event to callbacks. Set a callback while you verify:
Amplitude client = Amplitude.getInstance();
client.init("AMPLITUDE_API_KEY");
client.setCallbacks(new AmplitudeCallbacks() {
@Override
public void onLogEventServerResponse(Event event, int status, String message) {
System.out.println(event.eventType + ": " + status + " " + message);
}
});
client.logEvent(new Event("Sign Up Completed", "user-12345"));
A successful upload prints Sign Up Completed: 200 Event sent success.
status | message | What happened |
|---|---|---|
200 | Event sent success. | Amplitude accepted the event on the first attempt. |
200 | Events sent success. | Amplitude accepted the event on a retry. |
400 | Amplitude's error, such as Request missing required field | Amplitude rejected the request or this event. The SDK retries the other events in the request. |
413 | Event dropped for retry | The request was too large. The SDK dropped this event, which was in the second half of the batch, and retried the first half. |
429 | Amplitude's error, such as Too many requests for some devices and users | The event's user or device is over its daily quota. The SDK retries events for other users and devices. |
408, 500–599 | Event retries exhausted. | The request timed out, failed on the network, or got a server error on all 12 retries. |
0 | Error sending events due to the exception: ... | The upload failed with an exception: an invalid API key (AmplitudeInvalidAPIKeyException), an http:// server URL, or a flush timeout (TimeoutException). |
0 | Client shutdown. Events not retry. | You called shutdown() while the event waited for a retry. |
0 | Retry threads Exception. | A retry thread failed. The debug log shows a RETRY error with the stack trace. |
| Any | Retry buffer is full(N), M events dropped. | 16,000 events already waited for a retry. Slow down your logEvent() calls with shouldWait(). |
Events dropped by middleware, and events still in the queue when you call shutdown() without flushEvents(), get no callback.
Find the event in Amplitude
- In Amplitude, open User Lookup and search for the user ID or device ID of the event.
- Open the Activity tab and turn on Live event updates.
- Confirm that the event appears with the properties you set.
If the callback reported 200 but the event doesn't appear, check that the API key belongs to the project you're looking at, and that the server URL matches the project's data center.
これは役に立ちましたか?
For AI agents: a documentation index is available at /docs/llms.txt. Append .md to any page URL for markdown, or send Accept: text/markdown.