chore: Add tracing around key presenters

This commit is contained in:
Tom Moor
2022-04-27 18:59:17 -07:00
parent 576497eca1
commit d8fed83736
4 changed files with 28 additions and 7 deletions

View File

@@ -1,7 +1,8 @@
import { sortNavigationNodes } from "@shared/utils/collections";
import { APM } from "@server/logging/tracing";
import Collection from "@server/models/Collection";
export default function present(collection: Collection) {
function present(collection: Collection) {
const data = {
id: collection.id,
url: collection.url,
@@ -35,3 +36,8 @@ export default function present(collection: Collection) {
return data;
}
export default APM.traceFunction({
serviceName: "presenter",
spanName: "collection",
})(present);

View File

@@ -1,4 +1,5 @@
import { escapeRegExp } from "lodash";
import { APM } from "@server/logging/tracing";
import { Document } from "@server/models";
import Attachment from "@server/models/Attachment";
import parseAttachmentIds from "@server/utils/parseAttachmentIds";
@@ -29,7 +30,7 @@ async function replaceImageAttachments(text: string) {
return text;
}
export default async function present(
async function present(
document: Document,
options: Options | null | undefined = {}
) {
@@ -81,3 +82,8 @@ export default async function present(
return data;
}
export default APM.traceFunction({
serviceName: "presenter",
spanName: "document",
})(present);

View File

@@ -1,3 +1,4 @@
import { APM } from "@server/logging/tracing";
import { User } from "@server/models";
type Policy = {
@@ -5,10 +6,7 @@ type Policy = {
abilities: Record<string, boolean>;
};
export default function present(
user: User,
objects: Record<string, any>[]
): Policy[] {
function present(user: User, objects: Record<string, any>[]): Policy[] {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { serialize } = require("../policies");
@@ -17,3 +15,8 @@ export default function present(
abilities: serialize(user, object),
}));
}
export default APM.traceFunction({
serviceName: "presenter",
spanName: "policy",
})(present);

View File

@@ -1,3 +1,4 @@
import { APM } from "@server/logging/tracing";
import { Document, Collection, Team } from "@server/models";
type Action = {
@@ -7,7 +8,7 @@ type Action = {
value: string;
};
export default function present(
function present(
document: Document,
collection: Collection,
team: Team,
@@ -31,3 +32,8 @@ export default function present(
actions,
};
}
export default APM.traceFunction({
serviceName: "presenter",
spanName: "slackAttachment",
})(present);