-
-
Notifications
You must be signed in to change notification settings - Fork 17
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 basic tracing to Cloudflare Workers #243
Conversation
👋 Thanks for opening a pull request!If you are new, please check out the trimmed down summary of our deployment process below:
Please note, if you have a more complex change, it is advised to claim a deployment lock with Once your PR has been merged, you can remove the lock with |
Well that is odd 🤔 logs |
The shortname for the Car battery seems to have changed. This fixes that in our CI tests
Closing as outdated |
Adds auto and manual instrumentation to the cloudflare workers.
A tracer is initialized by reading the
OTEL_ENDPOINT
environment variable, which tells the tracer where to send the processed results.When the worker is triggered, a new trace operation is started automatically by the instrument call in main.js. First, the head sampler determines if the request should be actually sampled and logged, using the
ratio
value. Ratio can be set by setting aTRACE_RATIO
environment variable to a value between 0 (never) and 1 (always). By default, production will sample 0.05 (5%) of the requests from there it automatically instruments things like fetch calls, and KV loads. Non-production environments will default to 1.0 (100%) sample rates.All traces are set to tag the traces with a service name of
tarkov-api
, a namespace oftarkov-dev.{ENVIRONMENT}
, and a version of{TAPI_COMMIT_REF}
(intended to be set on deploy), falling back tounknown
.Several methods of some interest have been manually instrumented, by wrapping them in the
tracer.startActiveSpan
call. Each instrumented span will record the duration the function took to execute. Spans can have attributes and events associated with them, to add extra details for analysis and debugging.Important note: To make this possible, I had to remove the
node_compat
flag, and replace it withnodejs_compat
- this does require some care when integrating with some libraries that don't support thenode:
prefix for built-in packages