feat: add API performance observability reporting

This commit is contained in:
dahyeon committed 2026-06-28 00:40:05 -07:00
1 parent 871a5fe78a
commit 88de2148ae
14 files changed
+2082 -1

No files matched your search

@@ -11,6 +11,10 @@ interface NewRelicCustomEventApi {
eventType: string,
attributes: Record<string, NewRelicAttributeValue>,
): void;
addCustomAttributes(
attributes: Record<string, NewRelicAttributeValue>,
): void;
setTransactionName(name: string): void;
}
const agent = newrelicAgent as unknown as NewRelicCustomEventApi;
@@ -37,3 +41,25 @@ export function recordNewRelicCustomEvent(
// 관측성 실패가 비즈니스 로직을 막아선 안 된다.
}
}
export function addNewRelicCustomAttributes(
attributes: Record<string, NewRelicAttributeValue | undefined>,
): void {
try {
const flat: Record<string, NewRelicAttributeValue> = {};
for (const [key, value] of Object.entries(attributes)) {
if (value !== undefined) flat[key] = value;
}
agent.addCustomAttributes(flat);
} catch {
// 관측성 실패가 비즈니스 로직을 막아선 안 된다.
}
}
export function setNewRelicTransactionName(name: string): void {
try {
agent.setTransactionName(name);
} catch {
// 관측성 실패가 비즈니스 로직을 막아선 안 된다.
}
}