Skip to main content

Statistics / Usage-Reporting

Symphony has a built-in statistic reporting mechanism.

Prerequisites

Dependency Versions

The minimum required versions for symphony and symphony-cli are as follows:

PackageVersion
symphony@stechquick/symphony@0.1.7
symphony-cli@stechquick/symphony-cli@0.5.10

ReportingUrl

Reporting Endpoint to handle Symphony Stats reporting requests. (should be set to reportUrl)

Activation

Statistics reporting can be activated by adding a stats: key in config.yaml inside sym-engine folder in project root. Stats key should be added to each environment section in config.yaml

Usage Example

default: # Environment Section
#...
stats:
#stats keys below
#...
production: # Environment Section
#...
stats:
#stats keys below
#...

Remarks

  • Stats can store usage statistics by function breakdown and total call count.
  • Stats stores statistics on memory until the application shuts down or crash or until successful reporting call (reportURL).
  • Stats does not lose usage statistics with unsuccessful reporting calls (reportURL). It continues cumulating data in memory. This results in the data in the memory spanning a larger time frame.
  • Stats changes states with unsuccessful reporting calls (reportURL). Normal -> Observing -> Failure.
    • Normal: Stats is in normal state. Reporting is done with time span and accumulated call count.
    • Observing: In the first error observing state kicks in. During this state time span calls continue and accumulated call count changes to observingState.samplingFrequency.
    • Failure: When samplings in the observing state reaches observingState.failureStateThreshold failure count Failure state starts. During this state accumulated call count is disabled. And time span based reporting switches to observingState.failureStateIntervalTime timespan. So, you can raise this interval during Failure State to protect backend from overload; OR; you can lower this interval during Failure State to prevent losing usage statistics in memory as you are in Failure State, usage statistics now have a larger data for a larger timespan.
  • Stats data in memory can be monitored on liveness endpoint.

Common Pitfalls

  • make sure you activated stats key under target environment section.
  • make sure you obtained endpoint url correctly and wrote it to endpointUrl in stats
  • make sure enough time or accumulated request calls occurred in your service.

Stats Key Structure

default structure of stats is presented below.

  stats:
reportUrl: "http://127.0.0.1:4321/" # [required]
# reportIntervalTime: 300000 #(5min) # [optional]
# reportIntervalCount: 200 # [optional]
# applicationName: my-sym-app # [optional]
# observingState: # [optional]
# samplingFrequency: 10 # [optional]
# failureStateThreshold: 3 # [optional]
# failureStateIntervalTime: 180000 #(3min) # [optional]
KeyDescriptionRequired TypeDefault Value
reportUrlEndpoint url to push statistic reporttruestring--
reportIntervalTimeTime span in milliseconds for pushing cumulative statistics to reportUrlfalsenumber 300000 -> (5min)
reportIntervalCountAccumulated number of calls if reached, to trigger reporting even reportIntervalTime is not reachedfalsenumber 200
applicationNameApplication name that can be used to define your application namefalsestring--
observingStateStats has reporting states. Below this section are the values to manipulate the behaviour of these states.falseobject--
observingState.samplingFrequencyReportURL monitoring sampling frequency during Observing state.falsenumber10
observingState.failureStateThresholdNumber of report failures (reportURL) during Observing state to switch to Failure state.falsenumber3
observingState.failureStateIntervalTimeTime span in milliseconds for pushing cumulative statistics to reportUrl during the Failure state.falsenumber 180000 -> (3min)

Stats Key Structure (ISBANK)

KeyDescriptionRequired TypeDefault Value
isbankMetricNameif you need to change metric namefalsestringbff.trx.cnt

Example Request Body (ISBANK)

{
"metrics": [
{
"metricName": "bff.trx.cnt",
"value": 2
}
]
}

Example Request Body (ISBANK) (With 'applicationName')

{
"applicationName": "<YOUR APP NAME IN PACKAGE.JSON>",
"metrics": [
{
"metricName": "bff.trx.cnt",
"value": 2
}
]
}