Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

perf(cloud): report usage to stripe only for orgs with usage in timeframe

Marc Klingene776af544fec
diff --git a/worker/src/ee/cloudUsageMetering/handleCloudUsageMeteringJob.ts b/worker/src/ee/cloudUsageMetering/handleCloudUsageMeteringJob.ts
index f9af81dff0..fa162868c9 100644
--- a/worker/src/ee/cloudUsageMetering/handleCloudUsageMeteringJob.ts
+++ b/worker/src/ee/cloudUsageMetering/handleCloudUsageMeteringJob.ts
@@ -121,14 +121,16 @@ export const handleCloudUsageMeteringJob = async (job: Job) => {
`Cloud Usage Metering Job for org ${org.id} - ${stripeCustomerId} stripe customer id - ${countObservations} observations`
);
- await stripe.billing.meterEvents.create({
- event_name: "tracing_observations",
- timestamp: meterIntervalEnd.getTime() / 1000,
- payload: {
- stripe_customer_id: stripeCustomerId,
- value: countObservations.toString(), // value is a string in stripe
- },
- });
+ if (countObservations > 0) {
+ await stripe.billing.meterEvents.create({
+ event_name: "tracing_observations",
+ timestamp: meterIntervalEnd.getTime() / 1000,
+ payload: {
+ stripe_customer_id: stripeCustomerId,
+ value: countObservations.toString(), // value is a string in stripe
+ },
+ });
+ }
countProcessedOrgs++;
countProcessedObservations += countObservations;