Skip to content

Commit

Permalink
chore: fix APM ?
Browse files Browse the repository at this point in the history
  • Loading branch information
josephpage committed Jun 17, 2024
1 parent 0572d6b commit b7a8965
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/oidc-provider/oidc.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,20 @@ export class OidcController {
'protocol/openid-connect/*',
'clients-registrations/*'
])
public mountedOidc(@Req() req: Request, @Res() res: Response): Promise<void> {
public async mountedOidc(
@Req() req: Request,
@Res() res: Response
): Promise<void> {
req.url = req.originalUrl.replace('/auth/realms/pass-emploi', '')

const span =
this.apmService.currentTransaction?.startSpan('node-oidc-provider')
try {
req.url = req.originalUrl.replace('/auth/realms/pass-emploi', '')
return this.callback(req, res)
const result = await this.callback(req, res)
span?.end()
return result
} catch (e) {
span?.end()
this.logger.error(e)
this.apmService.captureError(e)
throw e
Expand Down
3 changes: 3 additions & 0 deletions src/oidc-provider/oidc.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,9 @@ export class OidcService {
this.oidc.on('refresh_token.destroyed', refreshToken => {
this.logger.debug('REFRESH DESTROYED %j', refreshToken)
})
this.oidc.on('*', event =>
this.apmService.addLabels({ [event]: Date.now() })
)
this.oidc.proxy = true
}

Expand Down

0 comments on commit b7a8965

Please sign in to comment.