Skip to content

Commit

Permalink
feat: remove unique UUIDs
Browse files Browse the repository at this point in the history
  • Loading branch information
tschoffelen committed Sep 7, 2024
1 parent 1339a5e commit e7ce488
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
14 changes: 14 additions & 0 deletions packages/api/src/lib/errors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import slug from "slug";

const removeUniqueIds = (str) => {
return str.replace(/[a-f0-9]([a-f0-9-]{24,34})[a-f0-9]/g, "{id}");
};

export const getErrorKey = (error) => {
let key = `${error.type} ${error.message}`.trim() || "unknown";

key = removeUniqueIds(key);
key = key.substring(0, 200);

return slug(key);
};
6 changes: 2 additions & 4 deletions packages/api/src/routes/collector/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Hono } from "hono";
import slug from "slug";

import { getExpiryTime, put, update } from "../../lib/database";
import { saveHourlyStat } from "../../lib/stats";
import { getErrorKey } from "../../lib/errors";

const app = new Hono();

Expand Down Expand Up @@ -60,9 +60,7 @@ app.post("/", async (c) => {

// save error
if (span.error) {
const errorKey = slug(
`${span.error.type} ${span.error.message}`.trim() || "unknown",
);
const errorKey = getErrorKey(span.error);
await update({
Key: {
pk: `function#${span.region}#${span.name}`,
Expand Down

0 comments on commit e7ce488

Please sign in to comment.