Unverified Commit 634de3c4 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Add trace url on bootup (#26594)

* Add trace url on bootup

* Update whitelist -> accesslist

* Add name to webpack-invalidated
parent 4da94a3f
......@@ -76,7 +76,8 @@ export class ProfilingPlugin {
this.traceHookPair(
'webpack-invalidated',
compiler.hooks.invalid,
compiler.hooks.done
compiler.hooks.done,
() => ({ name: compiler.name })
)
}
}
......@@ -86,7 +87,8 @@ export class ProfilingPlugin {
this.traceHookPair(
'webpack-compilation',
compiler.hooks.beforeCompile,
compiler.hooks.afterCompile
compiler.hooks.afterCompile,
() => ({ name: compiler.name })
)
}
......
import { traceGlobals } from '../shared'
const TRACE_EVENT_WHITELIST = new Map(
const TRACE_EVENT_ACCESSLIST = new Map(
Object.entries({
'webpack-invalidated': 'WEBPACK_INVALIDATED',
})
)
const reportToTelemetry = (spanName: string, duration: number) => {
const eventName = TRACE_EVENT_WHITELIST.get(spanName)
const eventName = TRACE_EVENT_ACCESSLIST.get(spanName)
if (!eventName) {
return
}
......
import { randomBytes } from 'crypto'
import fetch from 'node-fetch'
import * as Log from '../../../build/output/log'
let traceId = process.env.TRACE_ID
if (!traceId) {
traceId = process.env.TRACE_ID = randomBytes(8).toString('hex')
}
const localEndpoint = {
serviceName: 'zipkin-query',
serviceName: 'nextjs',
ipv4: '127.0.0.1',
port: 9411,
}
const zipkinUrl = `http://${localEndpoint.ipv4}:${localEndpoint.port}/api/v2/spans`
const zipkinUrl = `http://${localEndpoint.ipv4}:${localEndpoint.port}`
const zipkinAPI = `${zipkinUrl}/api/v2/spans`
const reportToLocalHost = (
name: string,
......@@ -21,6 +20,12 @@ const reportToLocalHost = (
parentId?: string,
attrs?: Object
) => {
if (!traceId) {
traceId = process.env.TRACE_ID = randomBytes(8).toString('hex')
Log.info(
`Zipkin trace will be available on ${zipkinUrl}/zipkin/traces/${traceId}`
)
}
const body = [
{
traceId,
......@@ -35,11 +40,11 @@ const reportToLocalHost = (
]
// We intentionally do not block on I/O here.
fetch(zipkinUrl, {
fetch(zipkinAPI, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body),
}).catch(() => {})
}).catch(console.log)
}
export default reportToLocalHost
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment