Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add output for tail being in sampling mode #3146

Merged
merged 1 commit into from
May 8, 2023
Merged

Conversation

jspspike
Copy link
Contributor

@jspspike jspspike commented May 4, 2023

If a tail enters sampling mode, it will forward a message saying that it's in sampling mode. The tail will send message every time the messages reaches over 100 requests per second. If we feel like that's not enough we could change this to happen periodically every 5 seconds.

One thing to keep in mind is that this will add messages to the tail stream that aren't actual trace events. Not sure if that is a concern, especially since the the non --pretty format is structured with event types which has different fields per message.

Also for the --pretty format we consider using something like ink to pin the sampling mode message? Not sure if that would be too much of a breaking change for users who might pipe the output of --pretty format to other tools

Reviewer has performed the following, where applicable:

  • Checked for inclusion of relevant tests
  • Checked for inclusion of a relevant changeset
  • Checked for creation of associated docs updates
  • Manually pulled down the changes and spot-tested

@jspspike jspspike requested a review from a team as a code owner May 4, 2023 18:46
@changeset-bot
Copy link

changeset-bot bot commented May 4, 2023

🦋 Changeset detected

Latest commit: f8b03d0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
wrangler Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented May 4, 2023

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/4888006090/npm-package-wrangler-3146

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/3146/npm-package-wrangler-3146

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/4888006090/npm-package-wrangler-3146 dev path/to/script.js
Additional artifacts:
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/4888006090/npm-package-cloudflare-pages-shared-3146

Note that these links will no longer work once the GitHub Actions artifact expires.

@jspspike jspspike force-pushed the jspspike/tail-overload branch 3 times, most recently from bf7aac9 to 962617a Compare May 4, 2023 21:49
@codecov
Copy link

codecov bot commented May 4, 2023

Codecov Report

Merging #3146 (f8b03d0) into main (98e6630) will increase coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3146      +/-   ##
==========================================
+ Coverage   74.83%   74.87%   +0.04%     
==========================================
  Files         179      179              
  Lines       10813    10819       +6     
  Branches     2853     2856       +3     
==========================================
+ Hits         8092     8101       +9     
+ Misses       2721     2718       -3     
Impacted Files Coverage Δ
packages/wrangler/src/tail/createTail.ts 83.33% <ø> (ø)
packages/wrangler/src/tail/printing.ts 82.85% <100.00%> (+1.60%) ⬆️

... and 2 files with indirect coverage changes

@jspspike
Copy link
Contributor Author

jspspike commented May 8, 2023

Update on what I provided in the description above, I'm going to create a second PR with the pinned sampling mode warning and have this PR simply output the warning in the tail messages stream

Copy link
Contributor

@JacobMGEvans JacobMGEvans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, great work Josh

Comment on lines +112 to +114
function isTailInfo(event: TailEventMessage["event"]): event is TailInfo {
return Boolean(event && "message" in event && "type" in event);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Predicate Type Check, nice.

@@ -48,6 +50,10 @@ export function prettyPrintLogs(data: WebSocket.RawData): void {
).toLocaleString();

logger.log(`Alarm @ ${datetime} - ${outcome}`);
} else if (isTailInfo(eventMessage.event)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of else if's starting to getting added, we may want to start thinking about the code design here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a switch/reducer kind of pattern, or something to define the event state.

@jspspike jspspike merged commit 5b234cf into main May 8, 2023
@jspspike jspspike deleted the jspspike/tail-overload branch May 8, 2023 18:50
@github-actions github-actions bot mentioned this pull request May 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants