File tree Expand file tree Collapse file tree 2 files changed +17
-13
lines changed Expand file tree Collapse file tree 2 files changed +17
-13
lines changed Original file line number Diff line number Diff line change @@ -59,11 +59,13 @@ import { TracingManager } from "@gitpod/gitpod-protocol/lib/util/tracing";
59
59
import { TypeORM } from "@gitpod/gitpod-db/lib" ;
60
60
import { dbConnectionsEnqueued , dbConnectionsFree , dbConnectionsTotal } from "./prometheus-metrics" ;
61
61
import { getExperimentsClientForBackend } from "@gitpod/gitpod-protocol/lib/experiments/configcat-server" ;
62
+ import { installCtxLogAugmenter } from "./util/log-context" ;
62
63
if ( process . env . NODE_ENV === "development" ) {
63
64
require ( "longjohn" ) ;
64
65
}
65
66
66
67
log . enableJSONLogging ( "server" , process . env . VERSION , LogrusLogLevel . getFromEnv ( ) ) ;
68
+ installCtxLogAugmenter ( ) ;
67
69
68
70
// eslint-disable-next-line @typescript-eslint/no-floating-promises
69
71
( async ( ) => {
Original file line number Diff line number Diff line change @@ -26,17 +26,19 @@ function mapToLogContext(ctx: RequestContext): LogContextOptions {
26
26
27
27
// we are installing a special augmenter that enhances the log context if executed within `runWithContext`
28
28
// with a contextId and a contextTimeMs, which denotes the amount of milliseconds since the context was created.
29
- const augmenter : LogContext . Augmenter = ( ctx ) => {
30
- const requestContext = ctxTryGet ( ) ;
31
- let derivedContext : LogContextOptions = { } ;
32
- if ( requestContext ) {
33
- derivedContext = mapToLogContext ( requestContext ) ;
34
- }
35
- const result = {
36
- ...derivedContext ,
37
- ...ctx ,
29
+ export function installCtxLogAugmenter ( ) {
30
+ const augmenter : LogContext . Augmenter = ( ctx ) => {
31
+ const requestContext = ctxTryGet ( ) ;
32
+ let derivedContext : LogContextOptions = { } ;
33
+ if ( requestContext ) {
34
+ derivedContext = mapToLogContext ( requestContext ) ;
35
+ }
36
+ const result = {
37
+ ...derivedContext ,
38
+ ...ctx ,
39
+ } ;
40
+ // if its an empty object return undefined
41
+ return Object . keys ( result ) . length === 0 ? undefined : result ;
38
42
} ;
39
- // if its an empty object return undefined
40
- return Object . keys ( result ) . length === 0 ? undefined : result ;
41
- } ;
42
- LogContext . setAugmenter ( augmenter ) ;
43
+ LogContext . setAugmenter ( augmenter ) ;
44
+ }
You can’t perform that action at this time.
0 commit comments