# Tracing in Explore

* [Query editor](#tracinginexplore-queryeditor)
* [Trace View](#tracinginexplore-traceview)
  * [Header](#tracinginexplore-header)
  * [Minimap](#tracinginexplore-minimap)
  * [Span Filters](#tracinginexplore-spanfilters)
  * [Timeline](#tracinginexplore-timeline)
  * [Span details](#tracinginexplore-spandetails)
  * [Trace to logs](#tracinginexplore-tracetologs)
  * [Trace to metrics](#tracinginexplore-tracetometrics)
* [Node Graph](#tracinginexplore-nodegraph)
* [Service Graph](#tracinginexplore-servicegraph)
* [Data API](#tracinginexplore-dataapi)
  * [Data frame structure](#tracinginexplore-dataframestructure)

You can use Explore to query and visualize traces from tracing data sources.

***

### Query editor <a href="#tracinginexplore-queryeditor" id="tracinginexplore-queryeditor"></a>

You can query and search tracing data using a data source’s query editor.

Each data source can have it’s own query editor.

***

### Trace View <a href="#tracinginexplore-traceview" id="tracinginexplore-traceview"></a>

This section explains the elements of the Trace View.

#### Header <a href="#tracinginexplore-header" id="tracinginexplore-header"></a>

* Header title: Shows the name of the root span and trace ID.
* Search: Highlights spans containing the searched text.
* Metadata: Various metadata about the trace.

#### Minimap <a href="#tracinginexplore-minimap" id="tracinginexplore-minimap"></a>

Shows condensed view or the trace timeline. Drag your mouse over the minimap to zoom into smaller time range. Zooming will also update the main timeline, so it is easy to see shorter spans. Hovering over the minimap, when zoomed, will show Reset Selection button which resets the zoom.

#### Span Filters <a href="#tracinginexplore-spanfilters" id="tracinginexplore-spanfilters"></a>

Using span filters, you can filter your spans in the trace timeline viewer. The more filters you add, the more specific are the filtered spans.

You can add one or more of the following filters:

* Service name
* Span name
* Duration
* Tags (which include tags, process tags, and log fields)

#### Timeline <a href="#tracinginexplore-timeline" id="tracinginexplore-timeline"></a>

Shows list of spans within the trace. Each span row consists of these components:

* Expand children button: Expands or collapses all the children spans of selected span.
* Service name: Name of the service logged the span.
* Operation name: Name of the operation that this span represents.
* Span duration bar: Visual representation of the operation duration within the trace.

Clicking anywhere on the span row shows span details.

#### Span details <a href="#tracinginexplore-spandetails" id="tracinginexplore-spandetails"></a>

* Operation name.
* Span metadata.
* Tags: Any tags associated with this span.
* Process metadata: Metadata about the process that logged this span.
* Logs: List of logs logged by this span and associated key values.

#### Trace to logs <a href="#tracinginexplore-tracetologs" id="tracinginexplore-tracetologs"></a>

You can navigate from a span in a trace view directly to logs relevant for that span.

Click the document icon to open a split view in Explore with the configured data source and query relevant logs for the span.

#### Trace to metrics <a href="#tracinginexplore-tracetometrics" id="tracinginexplore-tracetometrics"></a>

You can navigate from a span in a trace view directly to metrics relevant for that span.

***

### Node Graph <a href="#tracinginexplore-nodegraph" id="tracinginexplore-nodegraph"></a>

You can optionally expand the node graph for the displayed trace. Depending on the data source, this can show spans of the trace as nodes in the graph, or as some additional context like service graph based on the current trace.

***

### Service Graph <a href="#tracinginexplore-servicegraph" id="tracinginexplore-servicegraph"></a>

The Service Graph visualizes the span metrics (traces data for rates, error rates, and durations (RED)) and service graphs. Once the requirements are set up, this pre-configured view is immediately available.

***

### Data API <a href="#tracinginexplore-dataapi" id="tracinginexplore-dataapi"></a>

This visualization needs a specific shape of the data to be returned from the data source in order to correctly display it.

Data source needs to return data frame and set `frame.meta.preferredVisualisationType = 'trace'`.

#### Data frame structure <a href="#tracinginexplore-dataframestructure" id="tracinginexplore-dataframestructure"></a>

Required fields:

| Field name   | Type                 | Description                                                                                                                         |
| ------------ | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| traceID      | string               | Identifier for the entire trace. There should be only one trace in the data frame.                                                  |
| spanID       | string               | Identifier for the current span. SpanIDs should be unique per trace.                                                                |
| parentSpanID | string               | SpanID of the parent span to create child parent relationship in the trace view. Can be `undefined` for root span without a parent. |
| serviceName  | string               | Name of the service this span is part of.                                                                                           |
| serviceTags  | TraceKeyValuePair\[] | List of tags relevant for the service.                                                                                              |
| startTime    | number               | Start time of the span in millisecond epoch time.                                                                                   |
| duration     | number               | Duration of the span in milliseconds.                                                                                               |

Optional fields:

| Field name     | Type                 | Description                                                        |
| -------------- | -------------------- | ------------------------------------------------------------------ |
| logs           | TraceLog\[]          | List of logs associated with the current span.                     |
| tags           | TraceKeyValuePair\[] | List of tags associated with the current span.                     |
| warnings       | string\[]            | List of warnings associated with the current span.                 |
| stackTraces    | string\[]            | List of stack traces associated with the current span.             |
| errorIconColor | string               | Color of the error icon in case span is tagged with `error: true`. |

***
