testRTC enables users to create custom metrics for test results. Since we can’t collect everything you have in mind, you can add your own metrics as custom ones. These will get collected, aggregated and reported as part of the test result and be accessible to you similar to all the other metrics that testRTC is already collecting.
There are a few interesting things you can do with custom metrics:
- Set metrics from timers you set in your test
- Use metrics as part of your test expectations
- Inject metrics through our integration API
rtcSetMetric()
Create a metric that will be collected by the testRTC server or updated its value. The metric will be placed as part of the aggregated test result report.
During the test, the metric’s value will be calculated and stored per agent.
At the end of the test, the last metric value will be presented in the single agent’s report and an aggregated value, of all agents in the test, will be presented in the summary report page.
Name | Type | Description |
---|---|---|
key | string | The name of the metric to set |
operation | string | Can be one of the following operations: “set” – set a new value for the metric “add” – add to the current value of the metric “sub” – subtract from the current value of the metric |
value | number | The value that will be used for the operation |
aggregate (optional) | string | The type of aggregation to use for this custom metric across agents in the same test run: “sum” – Sum the metric’s value across all agents “avg” – Calculate the average of this metric’s value across all agents If this argument is missing, “sum” will be used by default. |
Code example
client.rtcSetMetric("connected-calls", "add", 1);
client.rtcSetMetric("live-universe-everything", "set", 42);
rtcSetMetricFromTimer()
Create a metric that will hold the time elapsed from the timer start time. The metric will be placed as part of the aggregated test result report.
During the test, the metric’s value will be calculated and stored per agent.
At the end of the test, the last metric value will be presented in the single agent’s report and an aggregated value, of all agents in the test, will be presented in the summary report page.
For more about times, check the timer commands available in testRTC.
Name | Type | Description |
---|---|---|
metric name | string | The name of the metric to set |
timer key | string | The name of the timer |
client
.rtcStartTimer('myTimer')
.rtcGetTimer('myTimer', function(timer) {
client.rtcInfo('Time: %d', timer)
})
.rtcSetMetricFromTimer('tmetric', 'myTimer');
The code snippet above would result the following:
- time=100; .rtcStartTimer(‘myTimer’)
- time=150; .rtcGetTimer(‘myTimer’, …); timer=50
- time=180; .rtcSetMetricFromTimer(‘tmetric’, ‘myTimer’) tmetric=80