-
Notifications
You must be signed in to change notification settings - Fork 723
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add output for tail being in sampling mode (#3146)
- Loading branch information
Showing
5 changed files
with
64 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"wrangler": patch | ||
--- | ||
|
||
Added output for tail being in "sampling mode" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ import type { | |
ScheduledEvent, | ||
AlarmEvent, | ||
EmailEvent, | ||
TailInfo, | ||
} from "../tail/createTail"; | ||
import type { RequestInit } from "undici"; | ||
import type WebSocket from "ws"; | ||
|
@@ -56,10 +57,10 @@ describe("tail", () => { | |
await runWrangler("tail durable-object--websocket--response"); | ||
expect(std.out).toMatchInlineSnapshot(`""`); | ||
expect(std.warn).toMatchInlineSnapshot(` | ||
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mBeginning log collection requires restarting the Durable Objects associated with durable-object--websocket--response. Any WebSocket connections or other non-persisted state will be lost as part of this restart.[0m | ||
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mBeginning log collection requires restarting the Durable Objects associated with durable-object--websocket--response. Any WebSocket connections or other non-persisted state will be lost as part of this restart.[0m | ||
" | ||
`); | ||
" | ||
`); | ||
expect(std.err).toMatchInlineSnapshot(`""`); | ||
}); | ||
it("creates and then delete tails", async () => { | ||
|
@@ -503,10 +504,31 @@ describe("tail", () => { | |
) | ||
.replace(mockTailExpiration.toISOString(), "[mock expiration date]") | ||
).toMatchInlineSnapshot(` | ||
"Successfully created tail, expires at [mock expiration date] | ||
Connected to test-worker, waiting for logs... | ||
Email from:${mockEmailEventFrom} to:${mockEmailEventTo} size:${mockEmailEventSize} @ [mock event timestamp] - Ok" | ||
`); | ||
"Successfully created tail, expires at [mock expiration date] | ||
Connected to test-worker, waiting for logs... | ||
Email from:[email protected] to:[email protected] size:45416 @ [mock event timestamp] - Ok" | ||
`); | ||
}); | ||
|
||
it("logs tail overload message", async () => { | ||
const api = mockWebsocketAPIs(); | ||
await runWrangler("tail test-worker --format pretty"); | ||
|
||
const event = generateTailInfo(); | ||
const message = generateMockEventMessage({ event }); | ||
const serializedMessage = serialize(message); | ||
|
||
api.ws.send(serializedMessage); | ||
expect( | ||
std.out.replace( | ||
mockTailExpiration.toISOString(), | ||
"[mock expiration date]" | ||
) | ||
).toMatchInlineSnapshot(` | ||
"Successfully created tail, expires at [mock expiration date] | ||
Connected to test-worker, waiting for logs... | ||
Tail is currently in sampling mode due to the high volume of messages. To prevent messages from being dropped consider adding filters." | ||
`); | ||
}); | ||
|
||
it("should not crash when the tail message has a void event", async () => { | ||
|
@@ -675,6 +697,7 @@ function isRequest( | |
| RequestEvent | ||
| AlarmEvent | ||
| EmailEvent | ||
| TailInfo | ||
| undefined | ||
| null | ||
): event is RequestEvent { | ||
|
@@ -956,3 +979,11 @@ function generateMockEmailEvent(opts?: Partial<EmailEvent>): EmailEvent { | |
rawSize: opts?.rawSize || mockEmailEventSize, | ||
}; | ||
} | ||
|
||
function generateTailInfo(): TailInfo { | ||
return { | ||
message: | ||
"Tail is currently in sampling mode due to the high volume of messages. To prevent messages from being dropped consider adding filters.", | ||
type: "overload", | ||
}; | ||
} |
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