forked from open-telemetry/opentelemetry-demo
-
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.
Revert "looks like formatting, and change pino to bunyan"
This reverts commit db00a95.
- Loading branch information
Showing
5 changed files
with
258 additions
and
198 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,24 @@ | ||
import { NextResponse } from 'next/server'; | ||
import type { NextRequest } from 'next/server'; | ||
import { NextResponse } from 'next/server' | ||
import type { NextRequest } from 'next/server' | ||
import { logger } from './utils/logger'; | ||
|
||
// This function can be marked `async` if using `await` inside | ||
export function middleware(request: NextRequest) { | ||
const startTime = Date.now(); | ||
const requestId = request.headers.get('x-request-id'); | ||
const response = NextResponse.next(); | ||
const duration = Date.now() - startTime; | ||
logger.info({ | ||
'log.source': 'middleware.ts', | ||
'http.method': request.method, | ||
'request.id': requestId, | ||
'http.url': request.url, | ||
'http.status': response.status, | ||
duration_ms: duration, | ||
}); | ||
return response; | ||
const startTime = Date.now(); | ||
const requestId = request.headers.get('x-request-id'); | ||
const response = NextResponse.next(); | ||
const duration = Date.now() - startTime; | ||
logger.info(JSON.stringify({ | ||
"timestamp": new Date().toISOString(), | ||
"http.method": request.method, | ||
"request.id": requestId, | ||
"http.url": request.url, | ||
"http.status": response.status, | ||
"duration_ms": duration})); | ||
return response; | ||
} | ||
|
||
// See "Matching Paths" below to learn more | ||
export const config = { | ||
matcher: '/(.*)', | ||
}; | ||
} |
Oops, something went wrong.