Skip to content

Commit

Permalink
fix(functions): reserved function field naming
Browse files Browse the repository at this point in the history
  • Loading branch information
Renc17 authored and kkopanidis committed Dec 19, 2024
1 parent 9f1f901 commit 68edd5f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
7 changes: 5 additions & 2 deletions modules/functions/src/admin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,13 @@ export class AdminHandlers {
};
const { success } = call.request.queryParams as { success: boolean };
const functionExecutions = await FunctionExecutions.getInstance().findMany({
function: functionId,
serverlessFunction: functionId,
success: success,
});
const count = await FunctionExecutions.getInstance().countDocuments({
serverlessFunction: functionId,
success: success,
});
const count = await FunctionExecutions.getInstance().countDocuments({});
return { functionExecutions, count };
}

Expand Down
2 changes: 1 addition & 1 deletion modules/functions/src/controllers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ async function executeFunction(
functionInSandbox(grpcSdk, call.request, (data: any) => {
const end = process.hrtime(start);
duration = end[0] * 1e3 + end[1] / 1e6;
addFunctionExecutions(name, duration, true, undefined, logs).then();
addFunctionExecutions(func._id, duration, true, undefined, logs).then();
ConduitGrpcSdk.Metrics?.increment('executed_functions_total');
ConduitGrpcSdk.Metrics?.observe('function_execution_time', duration, {
function_name: name,
Expand Down
7 changes: 4 additions & 3 deletions modules/functions/src/models/FunctionExecutions.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import {
TYPE,
} from '@conduitplatform/grpc-sdk';
import { ConduitActiveSchema } from '@conduitplatform/module-tools';
import { Functions } from './Function.schema.js';

const schema: ConduitModel = {
_id: TYPE.ObjectId,
function: {
serverlessFunction: {
type: TYPE.Relation,
model: 'Functions',
model: Functions.name,
required: true,
},
duration: {
Expand Down Expand Up @@ -50,7 +51,7 @@ const collectionName = undefined;
export class FunctionExecutions extends ConduitActiveSchema<FunctionExecutions> {
private static _instance: FunctionExecutions;
_id!: string;
function!: string | Function;
serverlessFunction!: string | Functions;
duration!: number;
success!: boolean;
error?: Indexable;
Expand Down

0 comments on commit 68edd5f

Please sign in to comment.