Customize Network Monitoring
By default Finotes SDK monitors all OkHttp based calls for issues.
Whitelisting hosts
Using MonitoredHost in @FnObserve annotation, hosts can be whitelisted. Once set only HTTP(s) calls made to the whitelisted hosts will be tracked by the SDK.
Setting * in MonitoredHost will allow calls to all hosts to be monitored by the SDK.
Application Class:
- Java
- Kotlin
@FnObserve(HTTPMonitoring = {@MonitoredHost(host = "your-host.com")
, @MonitoredHost(host = "another-host.com")})
public class BlogApp extends Application {
@Override
public void onCreate() {
super.onCreate();
Fn.init(this);
}
}
@FnObserve(HTTPMonitoring = {@MonitoredHost(host = "your-host.com")
, @MonitoredHost(host = "another-host.com")})
class BlogApp: Application() {
override fun onCreate() {
super.onCreate()
Fn.init(this)
}
}
Dynamic Path Component
When API call issues are reported, issues from different urls are created as separate ticket.
This can cause large number of tickets generated for the same API incase the url contains an id or any other dynamic path components.
Application Class:
- Java
- Kotlin
@FnObserve(HTTPMonitoring = {@MonitoredHost(host = "*",
pathPatterns = {@PathPattern(path = "/{id}/{another_id}/path_element"),
@PathPattern(path = "/path_element/{id}")})})
public class BlogApp extends Application {
@Override
public void onCreate() {
super.onCreate();
Fn.init(this);
}
}
@FnObserve(HTTPMonitoring = {@MonitoredHost(host = "*",
pathPatterns = {@PathPattern(path = "/{id}/{another_id}/path_element"),
@PathPattern(path = "/path_element/{id}")})})
class BlogApp: Application() {
override fun onCreate() {
super.onCreate()
Fn.init(this)
}
}
Use pathPatterns with @MonitoredHost annotation to specify the urls that contains dynamic path component.
Wrap the corresponding dynamic path components or id inside curly braces.
Here call to any host (as * is used in @MonitoredHost) that matches each specified pattern will be grouped into a single ticket for each PathPattern.
Privacy
As Finotes reports API call issues, each issue is tagged with corresponding request response headers, request body and associated parameters.
If header fields contain any sensitive data, Finotes provides a global and easy mechanism to mask such header fields using maskedHeaders in @FnObserve annotation as shown in code snippet.
You may provide 1 or more header keys in the 'maskedHeaders' field.
Application Class:
- Java
- Kotlin
@FnObserve(HTTPMonitoring = {@MonitoredHost(host = "*",
pathPatterns = {@PathPattern(path = "*", maskedHeaders = {"X-Key"})
@PathPattern(path = "/users", maskedHeaders = {"X-Key", "Accept"})})})
public class BlogApp extends Application {
@Override
public void onCreate() {
super.onCreate();
Fn.init(this);
}
}
@FnObserve(HTTPMonitoring = {@MonitoredHost(host = "*",
pathPatterns = {@PathPattern(path = "*", maskedHeaders = {"X-Key"})
@PathPattern(path = "/users", maskedHeaders = {"X-Key", "Accept"})})})
class BlogApp: Application() {
override fun onCreate() {
super.onCreate()
Fn.init(this)
}
}
Here X-Key header field will be filtered from calls to all hosts and endpoints before reporting an issue to Finotes dashboard while Accept header filed will be filtered from calls to all hosts but from only the endpoint that matches the given PathPattern.
Setting Host or Endpoint timeout
Developers can set timeout to endpoints using the networkTimeout key.
The timeout value should be in milliseconds. Once the value is set if any of the HTTP(s) calls to the host with endpoint takes more than the set amount of time, an issue report will be raised.
Application Class:
- Java
- Kotlin
@FnObserve(HTTPMonitoring = {@MonitoredHost(host = "*",
pathPatterns = {@PathPattern(path = "*", networkTimeout = 4000)
@PathPattern(path = "/fileUpload", networkTimeout = 50000)})})
public class BlogApp extends Application {
@Override
public void onCreate() {
super.onCreate();
Fn.init(this);
}
}
@FnObserve(HTTPMonitoring = {@MonitoredHost(host = "*",
pathPatterns = {@PathPattern(path = "*", networkTimeout = 4000)
@PathPattern(path = "/fileUpload", networkTimeout = 50000)})})
class BlogApp: Application() {
override fun onCreate() {
super.onCreate()
Fn.init(this)
}
}