-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #401 from vechr/feat/observability
Feat/observability
- Loading branch information
Showing
12 changed files
with
1,025 additions
and
19 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Injectable, NestMiddleware } from '@nestjs/common'; | ||
import { NextFunction } from 'express'; | ||
import { Span } from 'nestjs-otel'; | ||
|
||
@Injectable() | ||
export class InstrumentMiddleware implements NestMiddleware { | ||
@Span('Instrument Middleware') | ||
use(_req: Request, _res: Response, next: NextFunction) { | ||
next(); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { | ||
CompositePropagator, | ||
W3CTraceContextPropagator, | ||
W3CBaggagePropagator, | ||
} from '@opentelemetry/core'; | ||
import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base'; | ||
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'; | ||
import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express'; | ||
import { NestInstrumentation } from '@opentelemetry/instrumentation-nestjs-core'; | ||
import { JaegerPropagator } from '@opentelemetry/propagator-jaeger'; | ||
import { B3InjectEncoding, B3Propagator } from '@opentelemetry/propagator-b3'; | ||
import { PrometheusExporter } from '@opentelemetry/exporter-prometheus'; | ||
import { NodeSDK } from '@opentelemetry/sdk-node'; | ||
import { AsyncLocalStorageContextManager } from '@opentelemetry/context-async-hooks'; | ||
import { PrismaInstrumentation } from '@prisma/instrumentation'; | ||
import { PinoInstrumentation } from '@opentelemetry/instrumentation-pino'; | ||
import appConstant from './constants/app.constant'; | ||
|
||
const otelSDK = new NodeSDK({ | ||
serviceName: appConstant.APP_NAME, | ||
metricReader: new PrometheusExporter({ | ||
port: 8081, | ||
}), | ||
spanProcessor: new BatchSpanProcessor( | ||
new OTLPTraceExporter({ | ||
url: appConstant.OTLP_HTTP_URL, | ||
}), | ||
), | ||
contextManager: new AsyncLocalStorageContextManager(), | ||
textMapPropagator: new CompositePropagator({ | ||
propagators: [ | ||
new JaegerPropagator(), | ||
new W3CTraceContextPropagator(), | ||
new W3CBaggagePropagator(), | ||
new B3Propagator(), | ||
new B3Propagator({ | ||
injectEncoding: B3InjectEncoding.MULTI_HEADER, | ||
}), | ||
], | ||
}), | ||
instrumentations: [ | ||
new ExpressInstrumentation(), | ||
new NestInstrumentation(), | ||
new PrismaInstrumentation(), | ||
new PinoInstrumentation(), | ||
], | ||
}); | ||
|
||
export default otelSDK; |
Oops, something went wrong.