🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
chore(worker): drop project_id tag from export volume metric for API integrations (#14656)
Niklas Semmler6f846724dfec
diff --git a/worker/src/__tests__/exportVolumeMetric.test.ts b/worker/src/__tests__/exportVolumeMetric.test.tsindex bc5e85b352..a0337f619d 100644--- a/worker/src/__tests__/exportVolumeMetric.test.ts+++ b/worker/src/__tests__/exportVolumeMetric.test.ts@@ -13,7 +13,7 @@ import {describe("recordExportVolume", () => {beforeEach(() => recordIncrement.mockClear());- it("emits the unified metric with the byte value", () => {+ it("emits the unified metric with the byte value and omits projectId for API integrations", () => {recordExportVolume({integration: "mixpanel",bytes: 1234,@@ -21,8 +21,8 @@ describe("recordExportVolume", () => {});expect(recordIncrement).toHaveBeenCalledWith(EXPORT_VOLUME_METRIC, 1234, {integration: "mixpanel",- projectId: "p1",});+ expect(recordIncrement.mock.calls[0][2]).not.toHaveProperty("projectId");});it("includes blob dimensions and omits undefined tags", () => {@@ -45,19 +45,20 @@ describe("recordExportVolume", () => {});});- it("omits API-integration tags that are not provided", () => {+ it("omits projectId and unprovided tags for posthog", () => {recordExportVolume({integration: "posthog",bytes: 7,projectId: "p3",});const tags = recordIncrement.mock.calls[0][2];+ expect(tags).not.toHaveProperty("projectId");expect(tags).not.toHaveProperty("destination_type");expect(tags).not.toHaveProperty("source");expect(tags).not.toHaveProperty("table");});- it("emits llmaj egress with only integration/projectId tags", () => {+ it("emits llmaj egress with only the integration tag", () => {recordExportVolume({integration: "llmaj",bytes: 5120,@@ -65,9 +66,9 @@ describe("recordExportVolume", () => {});expect(recordIncrement).toHaveBeenCalledWith(EXPORT_VOLUME_METRIC, 5120, {integration: "llmaj",- projectId: "p4",});const tags = recordIncrement.mock.calls[0][2];+ expect(tags).not.toHaveProperty("projectId");expect(tags).not.toHaveProperty("destination_type");expect(tags).not.toHaveProperty("source");expect(tags).not.toHaveProperty("table");diff --git a/worker/src/features/evaluation/__tests__/evalExecutionDeps.test.ts b/worker/src/features/evaluation/__tests__/evalExecutionDeps.test.tsindex 2fd711cb44..9c78b53392 100644--- a/worker/src/features/evaluation/__tests__/evalExecutionDeps.test.ts+++ b/worker/src/features/evaluation/__tests__/evalExecutionDeps.test.ts@@ -123,7 +123,7 @@ describe("createProductionEvalExecutionDeps", () => {expect(mockRecordIncrement).toHaveBeenCalledWith(EXPORT_VOLUME_METRIC,expectedBytes,- { integration: "llmaj", projectId: "project-123" },+ { integration: "llmaj" },);// Not the Zod _def form.const zodDefBytes = Buffer.byteLength(diff --git a/worker/src/services/exportVolumeMetric.ts b/worker/src/services/exportVolumeMetric.tsindex b5bccb014a..c1b2e4ce15 100644--- a/worker/src/services/exportVolumeMetric.ts+++ b/worker/src/services/exportVolumeMetric.ts@@ -13,6 +13,9 @@ type ExportVolume = {// On-wire egress bytes shipped this run: gzipped for blob/posthog/mixpanel,// uncompressed for llmaj (LLM requests aren't gzipped).bytes: number;+ // Only tagged for blob_storage (per-project egress cost attribution); the+ // API-based integrations (posthog/mixpanel/llmaj) omit it to keep custom+ // metric cardinality down.projectId: string;// Egress-cost classification; blob only (S3 / S3_COMPATIBLE / AZURE_*).destinationType?: string;@@ -26,7 +29,7 @@ type ExportVolume = {* Single metric for total outbound export volume, so egress can be summed* across integrations and split by `integration` / `destination_type` for* cost. Undefined tags are omitted so each integration sets only the- * dimensions it has.+ * dimensions it has. `projectId` is tagged for blob_storage only.*/export const recordExportVolume = ({integration,@@ -37,7 +40,8 @@ export const recordExportVolume = ({table,path,}: ExportVolume): void => {- const tags: Record<string, string> = { integration, projectId };+ const tags: Record<string, string> = { integration };+ if (integration === "blob_storage") tags.projectId = projectId;if (destinationType !== undefined) tags.destination_type = destinationType;if (source !== undefined) tags.source = source;if (table !== undefined) tags.table = table;