Skip to content

Commit

Permalink
fix: add return types and fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
devin-ai-integration[bot] and trajan0x committed Dec 19, 2024
1 parent e7846b0 commit 0bb8ea0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/tracing/src/middleware/express.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/tracing/src/middleware/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
15 changes: 8 additions & 7 deletions packages/tracing/src/pyroscope.ts
Original file line number Diff line number Diff line change
@@ -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<string, string>;
}

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,
Expand Down

0 comments on commit 0bb8ea0

Please sign in to comment.