Example NRQL queries of distributed trace data

New Relic's distributed tracing generates both Spanevents and Transaction events. You can create NRQL queries of this data for analysis or to create new charts and dashboards.

Example queries

Some example NRQL queries:

Datastore time percentile for an app
SELECT percentile(duration, 50, 95) FROM Span WHERE category = 'datastore' 
and appName = 'YOUR_APP_NAME' SINCE 4 hours ago TIMESERIES 1 minute
Datastore query time for an app, faceted by host
SELECT average(duration) FROM Span WHERE appName = 'YOUR_APP_NAME' 
and category = 'datastore' FACET host TIMESERIES 1 minute
Average duration for a method of a service, faceted by host
SELECT average(duration) FROM Span WHERE appName = 'YOUR_APP_NAME'
and name = 'FUNCTION_NAME' FACET host TIMESERIES 1 minute
Histogram of external services called by a service, faceted by external URI
SELECT histogram(duration, 10, 60) FROM Span WHERE category = 'http'
and appName = 'YOUR_APP_NAME' FACET `http.url` SINCE 4 hours ago
Average duration for external calls across all applications
SELECT average(duration) FROM Span WHERE category = 'http'
SINCE 4 hours ago FACET `http.url` TIMESERIES 1 minute

For more help

Recommendations for learning more: