Skip to content

Commit

Permalink
feat: supporitng pino-caller
Browse files Browse the repository at this point in the history
  • Loading branch information
almog8k committed Sep 18, 2024
1 parent f20f81c commit a99e3c2
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 71 deletions.
4 changes: 4 additions & 0 deletions config/custom-environment-variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
"prettyPrint": {
"__name": "LOG_PRETTY_PRINT_ENABLED",
"__format": "boolean"
},
"pinoCaller": {
"__name": "LOG_PINO_CALLER_ENABLED",
"__format": "boolean"
}
},
"tracing": {
Expand Down
3 changes: 2 additions & 1 deletion config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"telemetry": {
"logger": {
"level": "info",
"prettyPrint": false
"prettyPrint": false,
"pinoCaller": false
},
"tracing": {
"enabled": "true",
Expand Down
1 change: 1 addition & 0 deletions helm/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ data:
RESPONSE_COMPRESSION_ENABLED: {{ .Values.env.responseCompressionEnabled | quote }}
LOG_LEVEL: {{ .Values.env.logLevel | quote }}
LOG_PRETTY_PRINT_ENABLED: {{ .Values.env.logPrettyPrintEnabled | quote }}
LOG_PINO_CALLER_ENABLED: {{ .Values.env.logPinoCallerEnabled | quote }}
{{ if $tracing.enabled }}
TELEMETRY_TRACING_ENABLED: 'true'
TELEMETRY_TRACING_URL: {{ $tracing.url }}
Expand Down
1 change: 1 addition & 0 deletions helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ env:
protocol: TCP
logLevel: info
logPrettyPrintEnabled: false
logPinoCallerEnabled: false
responseCompressionEnabled: true
requestPayloadLimit: 1mb

Expand Down
119 changes: 53 additions & 66 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@godaddy/terminus": "^4.12.1",
"@map-colonies/error-express-handler": "^2.1.0",
"@map-colonies/express-access-log-middleware": "^2.0.1",
"@map-colonies/js-logger": "^1.0.1",
"@map-colonies/js-logger": "^1.1.0",
"@map-colonies/mc-model-types": "^17.1.6",
"@map-colonies/mc-priority-queue": "^8.1.1",
"@map-colonies/mc-utils": "^3.1.0",
Expand Down
6 changes: 3 additions & 3 deletions src/containerConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export const queueClientFactory = (container: DependencyContainer): QueueClient
const logger = container.resolve<Logger>(SERVICES.LOGGER);
const config = container.resolve<IConfig>(SERVICES.CONFIG);
const queueConfig = config.get<IJobManagerConfig>('jobManagement.config');
const httpRetryConfig = config.get<IHttpRetryConfig>('server.httpRetry');
const disableHttpClientLogs = config.get<boolean>('server.disableHttpClientLogs');
const httpRetryConfig = config.get<IHttpRetryConfig>('httpRetry');
const disableHttpClientLogs = config.get<boolean>('disableHttpClientLogs');
const jobManagerServiceName = 'JobManager';
const heartbeatServiceName = 'Heartbeat';
return new QueueClient(
Expand All @@ -45,7 +45,7 @@ export interface RegisterOptions {

export const registerExternalValues = (options?: RegisterOptions): DependencyContainer => {
const loggerConfig = config.get<LoggerOptions>('telemetry.logger');
const logger = jsLogger({ ...loggerConfig, prettyPrint: loggerConfig.prettyPrint, mixin: getOtelMixin() });
const logger = jsLogger({ ...loggerConfig, prettyPrint: loggerConfig.prettyPrint, mixin: getOtelMixin(), pinoCaller: loggerConfig.pinoCaller });

const metrics = new Metrics();
metrics.start();
Expand Down
1 change: 1 addition & 0 deletions tests/unit/mocks/configMock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const registerDefaultConfig = (): void => {
logger: {
level: 'info',
prettyPrint: false,
pinoCaller: false,
},
tracing: {
enabled: true, // Changed from string "true" to boolean true
Expand Down

0 comments on commit a99e3c2

Please sign in to comment.