-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: add tracing to collection API #236
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
585c9cb
feat: add tracing to collection API
jpetto 5a4ad15
update sentry for corpus and prospect API
jpetto 191e996
reduce prisma logging
jpetto ecd5be0
reduce logging level to 'info' in AWS
jpetto e914567
update README
jpetto 693b2a4
cleanup
jpetto a86912a
small README updates
jpetto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -214,9 +214,61 @@ pnpm update | |
pnpm build | ||
``` | ||
|
||
#### aws-sdk versions | ||
## Package Synchronization | ||
|
||
⚠ Keep aws-sdk versions in sync, because AWS sometimes introduces incompatibilities without notice. | ||
We use [Syncpack](https://jamiemason.github.io/syncpack/guide/getting-started/) to keep package versions consistent across servers, lambdas, and shared packages. Outside of the consistent functional expecations of using the same package version in all places, it's important to keep some package groups in sync to mitigate cross-package bugs, e.g AWS and Prisma packages. | ||
|
||
- When adding a new aws-sdk, pin it to the version used throughout the monorepo. | ||
- When upgrading aws-sdk, upgrade it consistently throughout the monorepo. | ||
The syncpack config can be found in the `./syncpackrc` file. | ||
|
||
There are two command line operations associated with Syncpack: | ||
|
||
1. `pnpm list-mismatches` will tell you if any packages are out of sync/in violation of the rules set in `.syncpackrc`. This should only happen if your current branch is changing packages/package versions. Our CI will error if the rules in `.syncpackrc` are in violation. | ||
|
||
2. `pnpm fix-mismatches` will automatically fix `package.json` files that are in violation of the rules set in `.syncpackrc` by changing package versions. This is a quick and easy way to perform an upgrade, but as with any operation that can change things at scale, be sure you check the result is what you expect. | ||
|
||
## Tracing (Servers Only - WIP) | ||
|
||
We leverage [Pocket's tracing package](https://www.npmjs.com/package/@pocket-tools/tracing) to perform traces in our `server` applications: | ||
|
||
- Collection API | ||
|
||
- [GCP Traces](<https://console.cloud.google.com/traces/list?project=moz-fx-pocket-prod-61fb&pageState=(%22traceIntervalPicker%22:(%22groupValue%22:%22P7D%22,%22customValue%22:null),%22traceFilter%22:(%22chips%22:%22%255B%257B_22k_22_3A_22service.name_22_2C_22t_22_3A10_2C_22v_22_3A_22_5C_22collection-api_5C_22_22_2C_22s_22_3Atrue_2C_22i_22_3A_22service.name_22%257D%255D%22))>) | ||
- [GCP Logs](https://cloudlogging.app.goo.gl/3Ft9tbRDo3cHfC9K7) | ||
- [Unleash feature flag](https://featureflags.getpocket.dev/projects/default/features/perm.content.tracing.collections) (Dev) | ||
- [Unleash feature flag](https://featureflags.readitlater.com/projects/default/features/perm.content.tracing.collections) (Prod) | ||
|
||
- Curated Corpus API (coming soon) | ||
- Prospect API (coming soon) | ||
|
||
Tracing is performed using Open Telemetry NPM packages that send trace data to a standalone collector ECS service in AWS, which in turn exports trace data to GCP. The Pocket tracing package also implements an | ||
[Open Telemetry package](https://www.npmjs.com/package/@opentelemetry/auto-instrumentations-node) that hooks into the Winston logger (which we implement via the Pocket `ts-logger` package) to auto-forward log data to GCP. | ||
|
||
### Enable/Disable Tracing in Prod & Dev | ||
|
||
Tracing can be enabled and disabled using an Unleash feature flag, which exists per service implementing tracing. | ||
|
||
To enable and configure the feature flag: | ||
|
||
1. Visit the feature flag URL for the environment in question (linked above) | ||
2. Toggle the `default` environment to "On" in the left hand "Enabled in environments" box | ||
3. Expand the `default` environment in the main, right-hand panel | ||
4. Click the ✎ pencil icon to edit the "Gradual rollout" strategy | ||
5. Move the "Rolleout" slider to 100% | ||
6. Click the "Variants" tab and adjust the "Payload" number to the sample rate you'd like for your traces | ||
- In production, this should usually be 1% (0.01) to begin with, and can be increased slowly if needed | ||
7. Click "Save strategy" | ||
8. After some requests have been made to the service, go look at traces in GCP (using links above) | ||
|
||
To disable tracing on a service, simply toggle the `default` environment to "Off". | ||
|
||
### Local Tracing | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔥 |
||
|
||
Local tracing is enabled by default and sends trace data to a Grafana Docker image. To view traces locally: | ||
|
||
1. Make sure the local service you want to trace has activity, e.g. by running a query in the Apollo Server Playground | ||
2. Navigate to the Grafana docker image endpoint at `http://localhost:3000/explore` | ||
3. Click "Explore" in the left hand menu | ||
4. In the dropdown at the top left of the middle pane, select "Tempo" | ||
5. In the main panel, select the "Service Graph" for "Query type" | ||
6. Click the service you want to view traces for and select "View traces" | ||
7. Trace away! |
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
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the extensive documentation 🙏