Skip to content

Latest commit

 

History

History
246 lines (207 loc) · 6.1 KB

nerdgraph-distributed-trace-data-tutorial.mdx

File metadata and controls

246 lines (207 loc) · 6.1 KB
title tags metaDescription redirects freshnessValidatedDate
NerdGraph tutorial: Viewing distributed trace details
APIs
NerdGraph
Examples
Use New Relic NerdGraph (our GraphQL API) to query your distributed trace data.
/docs/apis/graphql-api/tutorials/query-distributed-trace-data-using-graphql-api
/docs/apis/graphql-api/tutorials/nerdgraph-graphiql-distributed-trace-data-tutorial
never

You can use New Relic's NerdGraph GraphiQL explorer to query your distributed tracing data. This document explains:

  • Trace metadata that's only available with NerdGraph
  • Example queries of trace data

Trace metadata

In addition to span event and transaction event data, we calculate additional metadata about the trace and its span relationships. To query this metadata, go to the NerdGraph GraphiQL explorer at api.newrelic.com/graphiql.

Additional trace-level data:

  <th>
    Description
  </th>
</tr>
  <td>
    The duration of this trace in milliseconds.
  </td>
</tr>

<tr>
  <td>
    `entities`
  </td>

  <td>
    All [entities](/docs/using-new-relic/welcome-new-relic/get-started/glossary#entity) that are part of this trace.
  </td>
</tr>

<tr>
  <td>
    `entityCount`
  </td>

  <td>
    The number of entities that are part of this trace.
  </td>
</tr>

<tr>
  <td>
    `spanConnections`
  </td>

  <td>
    Parent/child IDs that represent all of the span relationships within this trace.
  </td>
</tr>

<tr>
  <td>
    `timestamp`
  </td>

  <td>
    The trace's start time in milliseconds since the Unix epoch]([https://currentmillis.com/](https://currentmillis.com/)).
  </td>
</tr>
Trace-level metadata
`durationMs`

Additional span-level data:

  <th>
    Description
  </th>
</tr>
  <td>
    For a client span, this indicates the type of entity called: `DATASTORE` or `EXTERNAL`.
  </td>
</tr>

<tr>
  <td>
    `entityGuid`
  </td>

  <td>
    The New Relic identifier for the entity that sent the span.
  </td>
</tr>

<tr>
  <td>
    `processBoundary`
  </td>

  <td>
    The position of a span with respect to the boundaries between processes: `ENTRY`, `EXIT`, or `IN_PROCESS`.
  </td>
</tr>

<tr>
  <td>
    `spanAnomalies`
  </td>

  <td>
    Anomalies detected for a span, compared to similar spans that occurred over the previous hours before this span occurred. Anomalous spans appear in the [trace UI](/docs/apm/distributed-tracing/ui-data/understand-use-distributed-tracing-data).
  </td>
</tr>
Span-level metadata
`clientType`

For more about trace structure and span relationships, see Trace structure.

Trace data query examples [#trace-query-examples]

Here are example NerdGraph queries of distributed tracing data:

This NerdGraph query example shows how to return all data for a trace by using a trace's [`traceId`](/attribute-dictionary/span/traceid). Note that `attributes` is used to return [`Span` event attributes](/docs/understand-dependencies/distributed-tracing/get-started/how-new-relic-distributed-tracing-works#trace-storage).
```graphql
{
  actor {
    distributedTracing {
      trace(traceId: "YOUR_TRACE_ID") {
        spans {
          attributes
          clientType
          durationMs
          entityGuid
          id
          name
          parentId
          processBoundary
          timestamp
          traceId
          spanAnomalies {
            anomalousValue
            anomalyType
            averageMeasure
          }
        }
      }
    }
  }
}
```

For more about trace structure and span relationships, see [Trace structure](/docs/understand-dependencies/distributed-tracing/get-started/how-new-relic-distributed-tracing-works#trace-structure).

<Collapser id="trace-data" title="Query span relationship data"

This NerdGraph query example shows how to return trace-level metadata about the relationships between spans:

```graphql
{
  actor {
    distributedTracing {
      trace(traceId: "YOUR_TRACE_ID") {
        id
        timestamp
        durationMs
        spanConnections {
          parent
          child
        }
      }
    }
  }
}
```

For more about trace structure and span relationships, see [Trace structure](/docs/understand-dependencies/distributed-tracing/get-started/how-new-relic-distributed-tracing-works#trace-structure).

<Collapser id="entity-data" title="Query data of the entities in a trace"

This NerdGraph query example returns the [entities](/docs/using-new-relic/welcome-new-relic/get-started/glossary#entity) associated with a trace and some data about those entities.

```graphql
{
  actor {
    distributedTracing {
      trace(traceId: "YOUR_TRACE_ID") {
        entities {
          name
          tags {
            key
          }
          account {
            name
          }
        }
      }
    }
  }
}
```