Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ generates, reads or writes an ID.
|---|---|
| **Returns immediately** | The HTTP call runs on one daemon thread the client owns. A Spigot plugin can report from the server thread and no tick waits on the network. |
| **Never throws** | A server that is down, slow, or rejecting the key is a dropped report, not an exception in your program. Drops are logged at `FINE` if you gave a logger, otherwise not at all. |
| **Bounded** | At most 256 reports wait to be sent; past that, new ones are dropped. A trace server that is unreachable for a week costs a few kilobytes, not your heap. |
| **Bounded** | At most 256 reports wait to be sent; past that, new ones are dropped without a log line, even at `FINE`. A trace server that is unreachable for a week costs a few kilobytes, not your heap. |
| **`close()` drains** | Reports already queued get up to the client timeout (5 s total) to be sent before the thread stops, so a CLI that reports and exits at once does not lose its event. Still bounded: an unreachable server delays exit by at most the timeout. |

## Opting out
Expand Down Expand Up @@ -175,8 +175,10 @@ tags:

- `tags:` starts at column 0 and is followed by indented `key: value` lines.
Values may be double-quoted, single-quoted or bare; blank lines and `#`
comments inside the block are skipped. The block ends at the next line that
is not indented, or at the end of the file.
comments inside the block are skipped, and so is any line indented
differently from the block's first entry. The block ends at the next line
that is not indented, or at the end of the file. An `enabled:` line inside
the block is a tag like any other, not the switch.
- An event's own tag always wins, and the program's version is the event's
own: a server-wide `version` never overwrites it.
- Entries the trace server would reject are dropped one by one, never the
Expand Down
9 changes: 8 additions & 1 deletion src/test/java/software/stephenson/trace/TraceClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -483,8 +483,12 @@ void queue_isBoundedAndDropsRatherThanGrows() throws Exception {
exchange.close();
});
slow.start();
RecordingHandler log = new RecordingHandler();
Logger logger = Logger.getLogger("TraceClientTest.flood");
logger.setLevel(Level.ALL);
logger.addHandler(log);
TraceClient client = TraceClient.builder("http://127.0.0.1:" + slow.getAddress().getPort(), "MyPlugin", "1.2.3")
.key("k").build();
.key("k").logger(logger).build();
int flood = TraceClient.QUEUE_CAPACITY * 3;

// Act
Expand All @@ -509,6 +513,9 @@ void queue_isBoundedAndDropsRatherThanGrows() throws Exception {
"delivered " + delivered.get() + " of " + flood + "; at most the in-flight one plus a full queue may survive");
assertTrue(delivered.get() < flood, "an unbounded queue would have delivered all " + flood);
client.close();
// Every delivered report was a 201, so any log line would be about a
// dropped one; the README says those drops are silent.
assertTrue(log.records.isEmpty(), "a full queue drops without logging, but logged: " + log.records.size());
slow.stop(0);
}

Expand Down
Loading