Fix Honeycomb trace labels for API endpoints
I'm learning that top-level traces should use operation_name as well as name, because name is the low-level thing that every trace gets (including child traces like db queries and net requests)! Also there was an incorrect label in one of these, and validPetPoses was missing it altogether
This commit is contained in:
parent
14ec4585d7
commit
fc6cb2dfdd
5 changed files with 32 additions and 5 deletions
|
@ -131,5 +131,8 @@ function normalizeItemName(name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async (req, res) => {
|
export default async (req, res) => {
|
||||||
beeline.withTrace({ name: "allWakaValues" }, () => handle(req, res));
|
beeline.withTrace(
|
||||||
|
{ name: "api/allWakaValues", operation_name: "api/allWakaValues" },
|
||||||
|
() => handle(req, res)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -67,5 +67,8 @@ async function handle(req, res) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async (req, res) => {
|
export default async (req, res) => {
|
||||||
beeline.withTrace({ name: "outfitImage" }, () => handle(req, res));
|
beeline.withTrace(
|
||||||
|
{ name: "api/outfitImage", operation_name: "api/outfitImage" },
|
||||||
|
() => handle(req, res)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -47,5 +47,8 @@ async function handle(req, res) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async (req, res) => {
|
export default async (req, res) => {
|
||||||
beeline.withTrace({ name: "uploadLayerImage" }, () => handle(req, res));
|
beeline.withTrace(
|
||||||
|
{ name: "api/sendFeedback", operation_name: "api/sendFeedback" },
|
||||||
|
() => handle(req, res)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -171,5 +171,8 @@ async function handle(req, res) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async (req, res) => {
|
export default async (req, res) => {
|
||||||
beeline.withTrace({ name: "uploadLayerImage" }, () => handle(req, res));
|
beeline.withTrace(
|
||||||
|
{ name: "api/uploadLayerImage", operation_name: "api/uploadLayerImage" },
|
||||||
|
() => handle(req, res)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
const beeline = require("honeycomb-beeline")({
|
||||||
|
writeKey: process.env["HONEYCOMB_WRITE_KEY"],
|
||||||
|
dataset:
|
||||||
|
process.env["NODE_ENV"] === "production"
|
||||||
|
? "Dress to Impress (2020)"
|
||||||
|
: "Dress to Impress (2020, dev)",
|
||||||
|
serviceName: "impress-2020-gql-server",
|
||||||
|
});
|
||||||
import connectToDb from "../src/server/db";
|
import connectToDb from "../src/server/db";
|
||||||
import { getPoseFromPetState, normalizeRow } from "../src/server/util";
|
import { getPoseFromPetState, normalizeRow } from "../src/server/util";
|
||||||
|
|
||||||
|
@ -83,7 +91,7 @@ async function getDistinctPetStates(db) {
|
||||||
return rows.map(normalizeRow);
|
return rows.map(normalizeRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async (req, res) => {
|
async function handle(req, res) {
|
||||||
const buffer = await getValidPetPoses();
|
const buffer = await getValidPetPoses();
|
||||||
|
|
||||||
// Cache for 1 hour. This will also cache at Vercel's CDN, so the function
|
// Cache for 1 hour. This will also cache at Vercel's CDN, so the function
|
||||||
|
@ -91,4 +99,11 @@ export default async (req, res) => {
|
||||||
res.setHeader("Cache-Control", "max-age=3600");
|
res.setHeader("Cache-Control", "max-age=3600");
|
||||||
|
|
||||||
res.status(200).send(buffer);
|
res.status(200).send(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async (req, res) => {
|
||||||
|
beeline.withTrace(
|
||||||
|
{ name: "api/validPetPoses", operation_name: "api/validPetPoses" },
|
||||||
|
() => handle(req, res)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue