Skip to content

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

chore: add logging to ingestion API (#4306)

Max Deichmann684159abd162
diff --git a/worker/src/services/IngestionService/index.ts b/worker/src/services/IngestionService/index.ts
index 8673a68036..502a3f717f 100644
--- a/worker/src/services/IngestionService/index.ts
+++ b/worker/src/services/IngestionService/index.ts
@@ -293,6 +293,7 @@ export class IngestionService {
minStartTime === Infinity
? undefined
: convertDateToClickhouseDateTime(new Date(minStartTime));
+
const [postgresObservationRecord, clickhouseObservationRecord, prompt] =
await Promise.all([
this.getPostgresRecord({
@@ -545,17 +546,30 @@ export class IngestionService {
},
});
+ logger.debug(
+ `Found internal model name ${internalModel?.modelName} (id: ${internalModel?.id}) for observation ${observationRecord.id}`,
+ );
+
const final_usage_details = this.getUsageUnits(
observationRecord,
internalModel,
);
const modelPrices = await this.getModelPrices(internalModel?.id);
+
const final_cost_details = IngestionService.calculateUsageCosts(
modelPrices,
observationRecord,
final_usage_details.usage_details ?? {},
);
+ logger.info(
+ `Calculated costs and usage for observation ${observationRecord.id} with model ${internalModel?.id}`,
+ {
+ cost: final_cost_details.cost_details,
+ usage: final_usage_details.usage_details,
+ },
+ );
+
return {
...final_usage_details,
...final_cost_details,
@@ -596,6 +610,10 @@ export class IngestionService {
model,
});
+ logger.info(
+ `Tokenized observation ${observationRecord.id} with model ${model.id}, input: ${newInputCount}, output: ${newOutputCount}`,
+ );
+
const newTotalCount =
newInputCount || newOutputCount
? (newInputCount ?? 0) + (newOutputCount ?? 0)