-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(server): wrong usage of optl (#6714)
- Loading branch information
Showing
11 changed files
with
182 additions
and
70 deletions.
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 |
---|---|---|
@@ -1,11 +1,32 @@ | ||
import { create, createEsmHooks } from 'ts-node'; | ||
import * as otel from '@opentelemetry/instrumentation/hook.mjs'; | ||
import { createEsmHooks, register } from 'ts-node'; | ||
|
||
const service = create({ | ||
const service = register({ | ||
experimentalSpecifierResolution: 'node', | ||
transpileOnly: true, | ||
logError: true, | ||
skipProject: true, | ||
}); | ||
const hooks = createEsmHooks(service); | ||
|
||
export const resolve = hooks.resolve; | ||
/** | ||
* @type {import('ts-node').NodeLoaderHooksAPI2} | ||
*/ | ||
const ts = createEsmHooks(service); | ||
|
||
/** | ||
* @type {import('ts-node').NodeLoaderHooksAPI2.ResolveHook} | ||
*/ | ||
export const resolve = (specifier, context, defaultResolver) => { | ||
return ts.resolve(specifier, context, (s, c) => { | ||
return otel.resolve(s, c, defaultResolver); | ||
}); | ||
}; | ||
|
||
/** | ||
* @type {import('ts-node').NodeLoaderHooksAPI2.LoadHook} | ||
*/ | ||
export const load = async (url, context, defaultLoader) => { | ||
return await otel.load(url, context, (u, c) => { | ||
return ts.load(u, c, defaultLoader); | ||
}); | ||
}; |
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
32 changes: 32 additions & 0 deletions
32
packages/backend/server/src/fundamentals/metrics/instrumentations.ts
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Instrumentation } from '@opentelemetry/instrumentation'; | ||
import { GraphQLInstrumentation } from '@opentelemetry/instrumentation-graphql'; | ||
import { HttpInstrumentation } from '@opentelemetry/instrumentation-http'; | ||
import { IORedisInstrumentation } from '@opentelemetry/instrumentation-ioredis'; | ||
import { NestInstrumentation } from '@opentelemetry/instrumentation-nestjs-core'; | ||
import { SocketIoInstrumentation } from '@opentelemetry/instrumentation-socket.io'; | ||
import prismaInstrument from '@prisma/instrumentation'; | ||
|
||
const { PrismaInstrumentation } = prismaInstrument; | ||
|
||
let instrumentations: Instrumentation[] = []; | ||
|
||
export function registerInstrumentations(): void { | ||
if (AFFiNE.metrics.enabled) { | ||
instrumentations = [ | ||
new NestInstrumentation(), | ||
new IORedisInstrumentation(), | ||
new SocketIoInstrumentation({ traceReserved: true }), | ||
new GraphQLInstrumentation({ | ||
mergeItems: true, | ||
ignoreTrivialResolveSpans: true, | ||
depth: 10, | ||
}), | ||
new HttpInstrumentation(), | ||
new PrismaInstrumentation({ middleware: false }), | ||
]; | ||
} | ||
} | ||
|
||
export function getRegisteredInstrumentations(): Instrumentation[] { | ||
return instrumentations; | ||
} |
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.