Skip to content

Commit

Permalink
chore: enable profiler for route sejour/admin
Browse files Browse the repository at this point in the history
  • Loading branch information
achauve committed Nov 4, 2024
1 parent f8a8c63 commit 2677c9f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ const yup = require("yup");
const DemandeSejour = require("../../services/DemandeSejour");
const logger = require("../../utils/logger");
const ValidationAppError = require("../../utils/validation-error");
const Sentry = require("@sentry/node");

const log = logger(module.filename);

module.exports = async function getByDepartementCodes(req, res, next) {
async function getByDepartementCodes(req, res, next) {
log.i("IN");
const { decoded } = req;
const { id: adminId } = decoded ?? {};
Expand Down Expand Up @@ -66,4 +67,19 @@ module.exports = async function getByDepartementCodes(req, res, next) {
} catch (error) {
return next(error);
}
}

module.exports = async function get(req, res, next) {
// create new Sentry trace manually to enable profiler for its nested span
return await Sentry.startNewTrace(async () => {
return await Sentry.startSpan(
{
name: `Profile ${req.method} ${req.baseUrl}/${req.path}`,
op: "http",
},
async () => {
return await getByDepartementCodes(req, res, next);
},
);
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ module.exports = async function get(req, res) {
return await Sentry.startNewTrace(async () => {
return await Sentry.startSpan(
{
name: `Profile ${req.method} ${req.path}`,
name: `Profile ${req.method} ${req.baseUrl}/${req.path}`,
op: "http",
},
async () => {
Expand Down

0 comments on commit 2677c9f

Please sign in to comment.