Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Only log interesting events

Manav Rathi49ddd287d0c5
diff --git a/infra/workers/tail/src/index.ts b/infra/workers/tail/src/index.ts
index bc874c6bca..178f63d81b 100644
--- a/infra/workers/tail/src/index.ts
+++ b/infra/workers/tail/src/index.ts
@@ -16,8 +16,20 @@ interface Env {
LOKI_PUSH_URL: string;
}
-const handleTail = async (events: TraceItem[], lokiPushURL: string) =>
- pushLogLine(Date.now(), JSON.stringify(events), lokiPushURL);
+const handleTail = async (events: TraceItem[], lokiPushURL: string) => {
+ for (const event of events.filter(hasLogOrException)) {
+ await pushLogLine(Date.now(), JSON.stringify(event), lokiPushURL);
+ }
+};
+
+/**
+ * Return true if any of the events in {@link events} has at least one log or
+ * exception.
+ *
+ * These are the
+ */
+const hasLogOrException = (event: TraceItem) =>
+ event.logs.length ?? event.exceptions.length;
/**
* Send a log entry to (Grafana) Loki
@@ -45,7 +57,7 @@ const pushLogLine = async (
body: JSON.stringify({
streams: [
{
- stream: { job: "cf-worker" },
+ stream: { job: "worker" },
values: [[`${timestampMs * 1e6}`, logLine]],
},
],