diff --git a/packages/tracing/src/middleware/express.ts b/packages/tracing/src/middleware/express.ts index 90531a7faf..48d356799b 100644 --- a/packages/tracing/src/middleware/express.ts +++ b/packages/tracing/src/middleware/express.ts @@ -5,7 +5,7 @@ export interface TracingMiddlewareConfig { serviceName?: string; } -export function tracingMiddleware(config: TracingMiddlewareConfig = {}) { +export function tracingMiddleware(config: TracingMiddlewareConfig = {}): (req: Request, res: Response, next: NextFunction) => void { const tracer = trace.getTracer(config.serviceName || 'rest-api'); return (req: Request, res: Response, next: NextFunction) => { diff --git a/packages/tracing/src/middleware/metrics.ts b/packages/tracing/src/middleware/metrics.ts index f4061d5da9..c1a715c24c 100644 --- a/packages/tracing/src/middleware/metrics.ts +++ b/packages/tracing/src/middleware/metrics.ts @@ -8,7 +8,7 @@ export interface MetricsMiddlewareConfig { serviceName: string; } -export function metricsMiddleware(config: MetricsMiddlewareConfig) { +export function metricsMiddleware(config: MetricsMiddlewareConfig): (req: Request, res: Response, next: NextFunction) => void { const meter = metrics.getMeter(config.serviceName); const requestDuration = meter.createHistogram(HTTP_REQUEST_DURATION, { diff --git a/packages/tracing/src/pyroscope.ts b/packages/tracing/src/pyroscope.ts index 2d6c9599d8..f1ba5bcafc 100644 --- a/packages/tracing/src/pyroscope.ts +++ b/packages/tracing/src/pyroscope.ts @@ -1,23 +1,24 @@ -const pyroscope = require('@pyroscope/nodejs'); +import pyroscope from '@pyroscope/nodejs'; export interface PyroscopeConfig { applicationName: string; - serverAddress: string; + serverAddress?: string; tags?: Record; } -export function startPyroscope(config: PyroscopeConfig): any { +export function startPyroscope(config: PyroscopeConfig): void { if (!process.env.PYROSCOPE_ENDPOINT) { - return null; + return; } - return pyroscope.init({ + pyroscope.init({ serverAddress: process.env.PYROSCOPE_ENDPOINT, - applicationName: config.applicationName, + appName: config.applicationName, tags: { ...config.tags, - hostname: process.env.HOSTNAME, + hostname: process.env.HOSTNAME || 'unknown', }, + // @ts-expect-error: pyroscope types are incomplete profilers: { cpu: true, heap: true,