[internal] Add submit log flag to forward logs to DD - #185
Conversation
… mocking situations
cf8ed19 to
27d4c05
Compare
| }, | ||
| "devDependencies": { | ||
| "typescript": "${pkg.devDependencies.typescript}", | ||
| "typescript": "${pkg.devDependencies.typescript}" |
There was a problem hiding this comment.
This is just a fix for the yarn cli create-plugin command that would produce a faulty package.json breaking any yarn run afterward.
|
|
||
| > Send some analytics data to Datadog internally. | ||
| > <br/> | ||
| > It gives you acces to the `context.sendLog()` function. |
There was a problem hiding this comment.
It seems like we don't give access to context.sendLog anymore, is this a breaking change?
There was a problem hiding this comment.
Good catch, we're still give access to the function, but it's not defined from there anymore.
I forgot to document it from the context now.
Will do.
sethfowler-datadog
left a comment
There was a problem hiding this comment.
Nice; this will be a very handy feature to have! LGTM.
|
|
||
| if (forward) { | ||
| stores.queue.push( | ||
| getSendLog(data)({ message: content, context: { plugin: name, status: type } }), |
There was a problem hiding this comment.
Nit: perhaps call getSendLog() once outside of this closure and capture the result?
There was a problem hiding this comment.
No strong feeling about it, but curious as to why?
| if (errors.length > 0) { | ||
| log.error( | ||
| `Error occurred while processing async queue:\n ${errors.join('\n ')}`, | ||
| ); |
There was a problem hiding this comment.
I wonder if it's worth setting forward: true here, so that these errors could have a chance to get reported to the server?
It'd admittedly be a bit of a pain, since you have to deal with the fact that the network request will get pushed onto stores.queue, so you'd have to handle that and do a second round of awaiting. (Presumably giving up on forward: true if there are still errors.) So, no strong feelings, but I figured it was worth considering at least.
There was a problem hiding this comment.
For now it would probably be correct, but the more we go, the more I'd be worried to get all kind of failures unrelated to "us".
Like it could fail from custom plugins for instance.
What and why?
This PR enhances our internal telemetry capabilities by implementing log forwarding to Datadog for better observability of build processes.
The changes enable us to monitor build plugin performance and issues in production environments while ensuring these operations don't impact build performance.
The list of changes can be daunting, but there is a lot of code moving but not a lot of actual changes/additions.
Moves:
loggercode has been split out.sendLog(to Datadog) has been extracted and moved to core helpers.GlobalContextnow use simpler and more contained argumentsdataandstores.Changes:
yarn cli create-plugincommand.Additions:
async-queue-plugin.{ forward: boolean }option to logger.Key improvements:
How?
The implementation is organized around three main themes:
1. Log Forwarding Infrastructure
submitLoghelper inpackages/core/src/helpers/log.tsto send logs to Datadog intake API.packages/factory/src/helpers/logger.ts) to support conditional log forwarding.log.error('New error happened.', { forward: true });to forward any log.context.sendLogfollowing the previous changes.2. Async Queue Plugin
@dd/async-queue-pluginto handle non-blocking operations during the buildcontext.queue(), allowing plugins to defer work without blocking builds.3. Architecture Improvements
timeLoggersmocking approach.GlobalStoresandGlobalDatatypes to strictly define what the global context is using.GlobalContextis now built fromdataandstorespassed as arguments.Hopefully this will offer new ways of understanding usages of the plugins while simplifying the architecture of the whole system.