chore: More tracing improvements
This commit is contained in:
@@ -142,6 +142,4 @@ export class Mailer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mailer = new Mailer();
|
export default new Mailer();
|
||||||
|
|
||||||
export default mailer;
|
|
||||||
|
|||||||
@@ -23,7 +23,8 @@
|
|||||||
import { SpanOptions } from "dd-trace";
|
import { SpanOptions } from "dd-trace";
|
||||||
import DDTags from "dd-trace/ext/tags";
|
import DDTags from "dd-trace/ext/tags";
|
||||||
import env from "@server/env";
|
import env from "@server/env";
|
||||||
import tracer, { setError } from "./tracer";
|
import tracer from "./tracer";
|
||||||
|
import * as Tracing from "./tracer";
|
||||||
|
|
||||||
type DDTag = typeof DDTags[keyof typeof DDTags];
|
type DDTag = typeof DDTags[keyof typeof DDTags];
|
||||||
|
|
||||||
@@ -64,20 +65,15 @@ export const traceFunction = (config: TraceConfig) => <
|
|||||||
env.ENVIRONMENT === "test"
|
env.ENVIRONMENT === "test"
|
||||||
? target
|
? target
|
||||||
: (function wrapperFn(this: any, ...args: P): R {
|
: (function wrapperFn(this: any, ...args: P): R {
|
||||||
const {
|
const { className, methodName = target.name, tags } = config;
|
||||||
className,
|
|
||||||
methodName = target.name,
|
|
||||||
spanName = "DEFAULT_SPAN_NAME",
|
|
||||||
makeSearchable: useAnalytics,
|
|
||||||
tags,
|
|
||||||
} = config;
|
|
||||||
const childOf = config.isRoot
|
const childOf = config.isRoot
|
||||||
? undefined
|
? undefined
|
||||||
: tracer.scope().active() || undefined;
|
: tracer.scope().active() || undefined;
|
||||||
|
|
||||||
|
const spanName = config.spanName || className || "DEFAULT_SPAN_NAME";
|
||||||
|
|
||||||
const resourceName = config.resourceName
|
const resourceName = config.resourceName
|
||||||
? config.resourceName
|
? config.resourceName
|
||||||
: className
|
|
||||||
? `${className}.${methodName}`
|
|
||||||
: methodName;
|
: methodName;
|
||||||
const spanOptions: SpanOptions = {
|
const spanOptions: SpanOptions = {
|
||||||
childOf,
|
childOf,
|
||||||
@@ -100,7 +96,7 @@ export const traceFunction = (config: TraceConfig) => <
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useAnalytics) {
|
if (config.makeSearchable) {
|
||||||
span.setTag(DDTags.ANALYTICS, true);
|
span.setTag(DDTags.ANALYTICS, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,7 +107,7 @@ export const traceFunction = (config: TraceConfig) => <
|
|||||||
if (output && typeof output.then === "function") {
|
if (output && typeof output.then === "function") {
|
||||||
output
|
output
|
||||||
.catch((error: Error) => {
|
.catch((error: Error) => {
|
||||||
setError(error, span);
|
Tracing.setError(error, span);
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
span.finish();
|
span.finish();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import ApiKey from "@server/models/ApiKey";
|
import ApiKey from "@server/models/ApiKey";
|
||||||
|
|
||||||
export default function present(key: ApiKey) {
|
export default function presentApiKey(key: ApiKey) {
|
||||||
return {
|
return {
|
||||||
id: key.id,
|
id: key.id,
|
||||||
name: key.name,
|
name: key.name,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Attachment } from "@server/models";
|
import { Attachment } from "@server/models";
|
||||||
|
|
||||||
export default function present(attachment: Attachment) {
|
export default function presentAttachment(attachment: Attachment) {
|
||||||
return {
|
return {
|
||||||
documentId: attachment.documentId,
|
documentId: attachment.documentId,
|
||||||
contentType: attachment.contentType,
|
contentType: attachment.contentType,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { AuthenticationProvider } from "@server/models";
|
import { AuthenticationProvider } from "@server/models";
|
||||||
|
|
||||||
export default function present(
|
export default function presentAuthenticationProvider(
|
||||||
authenticationProvider: AuthenticationProvider
|
authenticationProvider: AuthenticationProvider
|
||||||
) {
|
) {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Team } from "@server/models";
|
import { Team } from "@server/models";
|
||||||
|
|
||||||
export default function present(team: Team, isSignedIn = false) {
|
export default function presentAvailableTeam(team: Team, isSignedIn = false) {
|
||||||
return {
|
return {
|
||||||
id: team.id,
|
id: team.id,
|
||||||
name: team.name,
|
name: team.name,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import Collection from "@server/models/Collection";
|
import Collection from "@server/models/Collection";
|
||||||
|
|
||||||
export default function present(collection: Collection) {
|
export default function presentCollection(collection: Collection) {
|
||||||
return {
|
return {
|
||||||
id: collection.id,
|
id: collection.id,
|
||||||
url: collection.url,
|
url: collection.url,
|
||||||
|
|||||||
@@ -8,11 +8,13 @@ type Membership = {
|
|||||||
permission: CollectionPermission;
|
permission: CollectionPermission;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default (membership: CollectionGroup): Membership => {
|
export default function presentCollectionGroupMembership(
|
||||||
|
membership: CollectionGroup
|
||||||
|
): Membership {
|
||||||
return {
|
return {
|
||||||
id: `${membership.groupId}-${membership.collectionId}`,
|
id: `${membership.groupId}-${membership.collectionId}`,
|
||||||
groupId: membership.groupId,
|
groupId: membership.groupId,
|
||||||
collectionId: membership.collectionId,
|
collectionId: membership.collectionId,
|
||||||
permission: membership.permission,
|
permission: membership.permission,
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ type Options = {
|
|||||||
isPublic?: boolean;
|
isPublic?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
async function present(
|
async function presentDocument(
|
||||||
document: Document,
|
document: Document,
|
||||||
options: Options | null | undefined = {}
|
options: Options | null | undefined = {}
|
||||||
) {
|
) {
|
||||||
@@ -64,5 +64,5 @@ async function present(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default traceFunction({
|
export default traceFunction({
|
||||||
spanName: "presentDocument",
|
spanName: "presenters",
|
||||||
})(present);
|
})(presentDocument);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Event } from "@server/models";
|
import { Event } from "@server/models";
|
||||||
import presentUser from "./user";
|
import presentUser from "./user";
|
||||||
|
|
||||||
export default function present(event: Event, isAdmin = false) {
|
export default function presentEvent(event: Event, isAdmin = false) {
|
||||||
const data = {
|
const data = {
|
||||||
id: event.id,
|
id: event.id,
|
||||||
name: event.name,
|
name: event.name,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import path from "path";
|
|||||||
import { FileOperation } from "@server/models";
|
import { FileOperation } from "@server/models";
|
||||||
import { presentUser } from ".";
|
import { presentUser } from ".";
|
||||||
|
|
||||||
export default function present(data: FileOperation) {
|
export default function presentFileOperation(data: FileOperation) {
|
||||||
return {
|
return {
|
||||||
id: data.id,
|
id: data.id,
|
||||||
type: data.type,
|
type: data.type,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import Group from "@server/models/Group";
|
import Group from "@server/models/Group";
|
||||||
|
|
||||||
export default function present(group: Group) {
|
export default function presentGroup(group: Group) {
|
||||||
return {
|
return {
|
||||||
id: group.id,
|
id: group.id,
|
||||||
name: group.name,
|
name: group.name,
|
||||||
|
|||||||
@@ -8,14 +8,14 @@ type GroupMembership = {
|
|||||||
user?: ReturnType<typeof presentUser>;
|
user?: ReturnType<typeof presentUser>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default (
|
export default function presentGroupMembership(
|
||||||
membership: GroupUser,
|
membership: GroupUser,
|
||||||
options?: { includeUser: boolean }
|
options?: { includeUser: boolean }
|
||||||
): GroupMembership => {
|
): GroupMembership {
|
||||||
return {
|
return {
|
||||||
id: `${membership.userId}-${membership.groupId}`,
|
id: `${membership.userId}-${membership.groupId}`,
|
||||||
userId: membership.userId,
|
userId: membership.userId,
|
||||||
groupId: membership.groupId,
|
groupId: membership.groupId,
|
||||||
user: options?.includeUser ? presentUser(membership.user) : undefined,
|
user: options?.includeUser ? presentUser(membership.user) : undefined,
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Integration } from "@server/models";
|
import { Integration } from "@server/models";
|
||||||
|
|
||||||
export default function present(integration: Integration) {
|
export default function presentIntegration(integration: Integration) {
|
||||||
return {
|
return {
|
||||||
id: integration.id,
|
id: integration.id,
|
||||||
type: integration.type,
|
type: integration.type,
|
||||||
|
|||||||
@@ -8,11 +8,13 @@ type Membership = {
|
|||||||
permission: CollectionPermission;
|
permission: CollectionPermission;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default (membership: CollectionUser): Membership => {
|
export default function presentMembership(
|
||||||
|
membership: CollectionUser
|
||||||
|
): Membership {
|
||||||
return {
|
return {
|
||||||
id: `${membership.userId}-${membership.collectionId}`,
|
id: `${membership.userId}-${membership.collectionId}`,
|
||||||
userId: membership.userId,
|
userId: membership.userId,
|
||||||
collectionId: membership.collectionId,
|
collectionId: membership.collectionId,
|
||||||
permission: membership.permission,
|
permission: membership.permission,
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import { NotificationSetting } from "@server/models";
|
import { NotificationSetting } from "@server/models";
|
||||||
|
|
||||||
export default function present(setting: NotificationSetting) {
|
export default function presentNotificationSetting(
|
||||||
|
setting: NotificationSetting
|
||||||
|
) {
|
||||||
return {
|
return {
|
||||||
id: setting.id,
|
id: setting.id,
|
||||||
event: setting.event,
|
event: setting.event,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Pin } from "@server/models";
|
import { Pin } from "@server/models";
|
||||||
|
|
||||||
export default function present(pin: Pin) {
|
export default function presentPin(pin: Pin) {
|
||||||
return {
|
return {
|
||||||
id: pin.id,
|
id: pin.id,
|
||||||
documentId: pin.documentId,
|
documentId: pin.documentId,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ type Policy = {
|
|||||||
abilities: Record<string, boolean>;
|
abilities: Record<string, boolean>;
|
||||||
};
|
};
|
||||||
|
|
||||||
function present(user: User, objects: Record<string, any>[]): Policy[] {
|
function presentPolicy(user: User, objects: Record<string, any>[]): Policy[] {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
const { serialize } = require("../policies");
|
const { serialize } = require("../policies");
|
||||||
|
|
||||||
@@ -17,5 +17,5 @@ function present(user: User, objects: Record<string, any>[]): Policy[] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default traceFunction({
|
export default traceFunction({
|
||||||
spanName: "presentPolicy",
|
spanName: "presenters",
|
||||||
})(present);
|
})(presentPolicy);
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
|
import { traceFunction } from "@server/logging/tracing";
|
||||||
import { Revision } from "@server/models";
|
import { Revision } from "@server/models";
|
||||||
import presentUser from "./user";
|
import presentUser from "./user";
|
||||||
|
|
||||||
export default async function present(revision: Revision, diff?: string) {
|
async function presentRevision(revision: Revision, diff?: string) {
|
||||||
await revision.migrateVersion();
|
await revision.migrateVersion();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: revision.id,
|
id: revision.id,
|
||||||
documentId: revision.documentId,
|
documentId: revision.documentId,
|
||||||
@@ -13,3 +15,7 @@ export default async function present(revision: Revision, diff?: string) {
|
|||||||
createdBy: presentUser(revision.user),
|
createdBy: presentUser(revision.user),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default traceFunction({
|
||||||
|
spanName: "presenters",
|
||||||
|
})(presentRevision);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { SearchQuery } from "@server/models";
|
import { SearchQuery } from "@server/models";
|
||||||
|
|
||||||
export default function present(searchQuery: SearchQuery) {
|
export default function presentSearchQuery(searchQuery: SearchQuery) {
|
||||||
return {
|
return {
|
||||||
id: searchQuery.id,
|
id: searchQuery.id,
|
||||||
query: searchQuery.query,
|
query: searchQuery.query,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Share } from "@server/models";
|
import { Share } from "@server/models";
|
||||||
import { presentUser } from ".";
|
import { presentUser } from ".";
|
||||||
|
|
||||||
export default function present(share: Share, isAdmin = false) {
|
export default function presentShare(share: Share, isAdmin = false) {
|
||||||
const data = {
|
const data = {
|
||||||
id: share.id,
|
id: share.id,
|
||||||
documentId: share.documentId,
|
documentId: share.documentId,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ type Action = {
|
|||||||
value: string;
|
value: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
function present(
|
function presentSlackAttachment(
|
||||||
document: Document,
|
document: Document,
|
||||||
team: Team,
|
team: Team,
|
||||||
collection?: Collection | null,
|
collection?: Collection | null,
|
||||||
@@ -34,5 +34,5 @@ function present(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default traceFunction({
|
export default traceFunction({
|
||||||
spanName: "presentSlackAttachment",
|
spanName: "presenters",
|
||||||
})(present);
|
})(presentSlackAttachment);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Star } from "@server/models";
|
import { Star } from "@server/models";
|
||||||
|
|
||||||
export default function present(star: Star) {
|
export default function presentStar(star: Star) {
|
||||||
return {
|
return {
|
||||||
id: star.id,
|
id: star.id,
|
||||||
documentId: star.documentId,
|
documentId: star.documentId,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Subscription } from "@server/models";
|
import { Subscription } from "@server/models";
|
||||||
|
|
||||||
export default function present(subscription: Subscription) {
|
export default function presentSubscription(subscription: Subscription) {
|
||||||
return {
|
return {
|
||||||
id: subscription.id,
|
id: subscription.id,
|
||||||
userId: subscription.userId,
|
userId: subscription.userId,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Team } from "@server/models";
|
import { Team } from "@server/models";
|
||||||
|
|
||||||
export default function present(team: Team) {
|
export default function presentTeam(team: Team) {
|
||||||
return {
|
return {
|
||||||
id: team.id,
|
id: team.id,
|
||||||
name: team.name,
|
name: team.name,
|
||||||
|
|||||||
@@ -22,7 +22,10 @@ type UserPresentation = {
|
|||||||
preferences?: UserPreferences | null;
|
preferences?: UserPreferences | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default (user: User, options: Options = {}): UserPresentation => {
|
export default function presentUser(
|
||||||
|
user: User,
|
||||||
|
options: Options = {}
|
||||||
|
): UserPresentation {
|
||||||
const userData: UserPresentation = {
|
const userData: UserPresentation = {
|
||||||
id: user.id,
|
id: user.id,
|
||||||
name: user.name,
|
name: user.name,
|
||||||
@@ -43,4 +46,4 @@ export default (user: User, options: Options = {}): UserPresentation => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return userData;
|
return userData;
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { View } from "@server/models";
|
import { View } from "@server/models";
|
||||||
import { presentUser } from "../presenters";
|
import { presentUser } from "../presenters";
|
||||||
|
|
||||||
export default function present(view: View) {
|
export default function presentView(view: View) {
|
||||||
return {
|
return {
|
||||||
id: view.id,
|
id: view.id,
|
||||||
documentId: view.documentId,
|
documentId: view.documentId,
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export interface WebhookPresentation {
|
|||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function present({
|
export default function presentWebhook({
|
||||||
event,
|
event,
|
||||||
delivery,
|
delivery,
|
||||||
payload,
|
payload,
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import { WebhookSubscription } from "@server/models";
|
import { WebhookSubscription } from "@server/models";
|
||||||
|
|
||||||
export default function present(webhook: WebhookSubscription) {
|
export default function presentWebhookSubscription(
|
||||||
|
webhook: WebhookSubscription
|
||||||
|
) {
|
||||||
return {
|
return {
|
||||||
id: webhook.id,
|
id: webhook.id,
|
||||||
name: webhook.name,
|
name: webhook.name,
|
||||||
|
|||||||
Reference in New Issue
Block a user