Debugging Runscope Tests using Variables and Moesif Segmentation

2 minute read

Runscope is a great product for testing your APIs. We have many customers asking how to best compliment the synthetic API testing and stimuli generation from Runscope with the realtime monitoring and analytics from Moesif.

Runscope buckets

Runscope buckets are a way to organize tests and requests. If you have a mobile app that connects to ten different 3rd party APIs, you may create a bucket for each of those APIs. This way, all the tests for a specific company or service is organized in the same bucket.

Moesif segmentation

Moesif can filter and group by arbitrary fields in an API call such as the request route, the response status code or even an arbitrary HTTP request or response headers. Moesif can also tie multiple requests together as a trace using a unique session token. To organize Runscope test result data in Moesif, we can add additional headers in our test that Moesif can analyze.

Runscope test variables

Runscope tests support built-in variables and functions that can be added to a test API call such as in HTTP request headers. We should add them as custom HTTP request headers using the prefix X-Runscope

Runscope test editor

We recommend adding at least the following HTTP request headers to your Runscope tests: (Of course, don’t forget your X-Moeif-Application-Id)

Header Key Header Value Description
X-Runscope-Environment {{runscope_environment}} The name of the environment used for this test run.
X-Runscope-Environment-Uuid {{runscope_environment_uuid}} The unique ID of the environment used for this test run.
X-Runscope-Bucket {{runscope_bucket}} The bucket key for the Runscope Bucket the executing test is contained within.
X-Runscope-Bucket-Name {{runscope_bucket_name}} The name of the Runscope Bucket the executing test is contained within.
X-Runscope-Test-Uuid {{runscope_test_uuid}} The unique identifier for the Runscope test.
X-Runscope-Test-Name {{runscope_test_name}} The name of the Runscope test.
X-Runscope-Region {{runscope_region}} The region code indicating the location in which this test run was initiated.

For grouping all API requests from the same test into a single Moesif trace, we also recommend setting the X-Moesif-Session-Token header:

X-Moesif-Session-Token: {{runscope_test_uuid}}

Running the test

Once we run the test, we will see the events show up in Moesif event stream, which is like a traffic inspector but with filtering and analytics. Since we added the headers, we can use the Request Headers Filters on the left to filter by a specific test name.

For example, we can show only the events from the StressRandom test.

Runscope test editor

Investigating Runscope test analytics

Since the API test results is logged by Moesif, we can use any of the Moesif analytics charts such as Geo Heatmaps and Segmentation charts to dig into our test data deeper. For example, we can look at a breakdown of status codes for our StressRandom test.

Runscope test editor

Closing thoughts

Using Moesif and Runscope together can supercharge your API debug workflow so you can deliver great APIs. If you have any suggestions for improving how to use Runscope and Moesif together for an awesome API debug experience, feel free to let us know.

Moesif is the most advanced API Analytics platform. Thousands of API developers process billions of API calls through Moesif for debugging, monitoring and discovering insights.

Learn More

Leave a comment