Skip to content

Commit

Permalink
fix: #611 bcgw extract ocp route timeout (#613)
Browse files Browse the repository at this point in the history
* Adjust router timeout to 90s

* Add function performance measurement with info logging for /bcgw-extract endpoint.

* Increase router timeout to 120.
  • Loading branch information
ianliuwk1019 authored Apr 5, 2024
1 parent 8d49b1d commit c9cf822
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions api/openshift.deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ objects:
app: ${NAME}-${ZONE}
certbot-managed: ${CERTBOT}
name: ${NAME}-${ZONE}-${COMPONENT}
annotations:
haproxy.router.openshift.io/timeout: 120s # (Fix 611 - /bcgw-extract long time response in prod)
spec:
host: ${URL}
path: /${COMPONENT}
Expand Down
13 changes: 10 additions & 3 deletions api/src/app/modules/spatial-feature/spatial-feature.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { PinoLogger } from 'nestjs-pino';

import { SpatialFeatureBcgwResponse, SpatialFeaturePublicResponse } from './spatial-feature.dto';
import { SpatialFeatureService } from './spatial-feature.service';
import { performance } from 'perf_hooks';

@ApiTags('spatial-feature')
@Controller('spatial-feature')
Expand Down Expand Up @@ -31,9 +32,15 @@ export class SpatialFeatureController {
throw new BadRequestException('Invalid version');
}

this.logger.debug('Start get /spatial-feature/bcgw-extract'); // For measuring performance.

return this.spatialFeatureService.getBcgwExtract();
this.logger.info('Start get /spatial-feature/bcgw-extract'); // For measuring performance.

const start = performance.now();
const result = this.spatialFeatureService.getBcgwExtract();
const end = performance.now();

this.logger.info(`End get /spatial-feature/bcgw-extract for ${end - start}ms.`);

return result;
}

}

0 comments on commit c9cf822

Please sign in to comment.