Skip to main content
Version: 8.0.1

Track Function Calls

Function tracking is the ability to monitor code-level individual functions during runtime for any potential errors. Framework provides two different ways to activate function tracking.

  1. By using the Fn.call() API to invoke code level function, Finotes framework will be able to monitor and report runtime issues with detailed data points.
  2. By using the Fn.start() and Fn.end() APIs within the function definition, Framework will be able to monitor and report runtime issues with detailed data points.

Regular function call


[self getUserNameFromDb:@"123-sd-12"];
}

-(NSString *) getUserNameFromDb:(NSString *) userId {
NSString *userName = [[User findById:userId] name];
return userName;
}

Method 1 - Using Fn.call() API


#import <FinotesCore/Observer.h>
#import <FinotesCore/Fn.h>


[Fn call:@selector(getUserNameFromDb:) target:self withParameters:@"123-sd-12"];
}

-(NSString *) getUserNameFromDb:(NSString *) userId {
NSString *userName = [[User findById:userId] name];
return userName;
}

Once Fn.call() API is invoked, errors like NULL return value, wrong return value, exceptions and function execution delays will be captured and reported to the dashboard.

Things to Note:

  1. Replace the traditional method of function invocation with the Finotes based mechanism using Fn.call() API.
  2. The access modifier of the function should be set to public.
  3. Function parameters should be of an Object type. primitive data types are not supported by Fn.call() API.
  4. By default, framework monitors for nil return value, false return values in case of Boolean and if the function takes more than 1000 milliseconds to execute.
  5. Exceptions thrown during function execution will be automatically captured and reported.
  6. Please find the Observe fields section to learn more.
  7. The function parameters that were passed to it during its invocation will be tagged along with the issue in the Finotes dashboard if any are raised.

Method 2 - Using Fn.start() and Fn.end() APIs

Once Fn.start() and Fn.end() APIs are added to a function definition, errors like nil return value, wrong return values and function execution delays will be captured and reported to the dashboard.


#import <FinotesCore/Observer.h>
#import <FinotesCore/Fn.h>


[self getUserNameFromDb:@"123-sd-12"];
}

-(NSString *) getUserNameFromDb:(NSString *) userId {
[Fn start:[[Observer alloc] init] withParams:[NSArray arrayWithObjects:userId, nil]]; //Fn.start

NSString *userName = [[User findById:userId] name];

[Fn end:userName]; //Fn.end
return userName;
}

Things to Note:

  1. It is mandatory to call both Fn.start() and Fn.end() functions at the start and end of your function definition.
  2. First parameter of the Fn.start() function takes Observe object. Please find the Observe fields section to learn more.
  3. By default, framework monitors for nil return value, false return value in case of Boolean and if the function takes more than 1000 milliseconds to execute.
  4. Use Fn.reportException API to report exceptions thrown during function invocation.
  5. The function parameters that are passed to Fn.start() during its invocation will be tagged along with issues reported in the Finotes dashboard.
  6. In case there is no return value, just call Fn.end() at the end of the function definition.

Observe fields

You can make use of expectedExecutionTime, severity, expectNull fields in Observer parameter of Call / start API to control the issue reports from a function.
Observe fields allows customization in the way issues are reported during a tracked function execution.

Expected Execution Time

By default, if a tracked function takes more than 1000 milliseconds to execute, an issue report will be sent to the dashboard.
Set a custom expected execution time using the field expectedExecutionTime in Observe field.


#import <FinotesCore/Observer.h>
#import <FinotesCore/Fn.h>


{
Observer *observer = [[Observer alloc] init];
[observer expectedExecutionTime:3000]; //Pass observer to Fn.call or Fn.start API
}

Once this field is set with a custom value, and the corresponding function execution takes more than the set amount of time, an issue report will be sent to the dashboard.

Expect Nil

By default, if a tracked function returns Nil during its execution, an issue report will be sent to the dashboard.
Set the field expectNull to 'true' to prevent framework from reporting NULL issues.

Expected Boolean Value

By default, if a tracked function with return type Boolean returns 'false' during its execution, an issue report will be sent to the dashboard.
Instead if an issue report needs to be raised if return value is 'true', set the field expectedBooleanValue to 'false'.

Set Range Check of Return value

If the tracked function returns a Number type (e.g. Integer, Double, Float). Use min, max, minDecimal, maxDecimal fields to set expected upper and lower limits of return value.
Once set, if the function returns a value outside the min and max values, corresponding issue report will be raised to the Finotes dashboard.

Severity

By default, issues raised from a tracked function will have the default severity level - MAJOR. Use severity field to change the value. Available severity levels are MINOR, MAJOR, FATAL