# Distributed Tracing

**Distributed Tracing** enables tracking of requests as they pass through the microservices in a syste&#x6D;**.** Ddosify captures **Traces** and **Spans** out-of-the-box on your Kubernetes Cluster without modifying your code or restarting your services. Ddosify uses a lightweight [eBPF Agent (Alaz)](https://github.com/ddosify/alaz) to generate Distributed Tracing data and enable auto context propagation.

To do so, on the [Ddosify Platform](https://app.ddosify.com/), click "Clusters" under the "Observability" tab first.

<figure><img src="https://lh7-us.googleusercontent.com/jwKB_O5sondiEwSa7sYoj68H0mVQNdPzfsgTLIm--2VitdJijaxUi7qEURCVCrb1o-lCxQvp3VAnPMaXZGdgS-VT22YGWe-yrO4qQYSSHDLQNff006wkzMHSQ5qH01gof15eHeB17uaOkJVlbU-4-ec" alt=""><figcaption><p>Clusters Page</p></figcaption></figure>

After you click on a cluster you want to observe on the clusters page, click on the distributed tracing tab. This will take you to the distributed tracing page. You will see this:

<figure><img src="https://2539979715-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FugegoRCn84wtxrIelgft%2Fuploads%2FquV2oqpI4XSWhpNc9AYe%2Fimage.png?alt=media&#x26;token=9146744c-9eb6-4e9f-a0bc-31d1db0d4082" alt=""><figcaption><p>Distributed Tracing</p></figcaption></figure>

Here, you can filter and view traces in chart and list form.

### Filtering

You can apply the following filtering:

* Operations (trace names)
* Trace count
* Tags
* Min/max duration (in ms)
* Min/max span count
* Time interval

{% hint style="info" %}
**Note:** Filtering affects both the trace chart and the trace list. They show the same traces but in different formats.
{% endhint %}

To apply filtering, click the "Filters" button on the upper right.

<figure><img src="https://2539979715-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FugegoRCn84wtxrIelgft%2Fuploads%2FTAl0la5K2EJ72Zjw6QYO%2Fimage.png?alt=media&#x26;token=67267c8a-a596-4ad4-b25b-aa5b44c0feda" alt="" width="375"><figcaption><p>Trace filtering</p></figcaption></figure>

#### Operations

Operations filtering allows you to select traces with specific names. It allows multi-select so that you can look for multiple names.

{% hint style="info" %}
**Note:** The name of a trace is the name of its first span.
{% endhint %}

#### Max Results

This limits the number of traces shown.

#### Tags

Tags allow you to filter traces by the tags in their spans. Tag filtering accepts the [logfmt](https://brandur.org/logfmt) format.

{% hint style="info" %}
**Note:** Span attributes are not allowed to be nested; thus, tag filtering does not support nested filtering either.
{% endhint %}

Let's see how we can query traces by their tags. Let this be an example tags for a span:

```json
{
    "path": "/", 
    "to_ip": "192.168.20.73", 
    "method": "GET", 
    "to_uid": "d0210c8f-fe44-472c-bbb2-39d64973e5a4", 
    "from_ip": "192.168.30.206", 
    "to_name": "kube-state-metrics-shard", 
    "to_port": "8081", 
    "to_type": "daemonset", 
    "from_uid": "2148b55d-cab8-41c6-ab5e-b12d9630ba0c", 
    "protocol": "HTTP", 
    "from_name": "aws-node", 
    "from_port": "41736", 
    "from_type": "daemonset", 
    "status_code": "200"
}
```

An example tag filter could look like this:

```
method=GET protocol=HTTP from_port=41736
```

While filtering, it is enough for a single span of a trace to satisfy this filter. As a result, the traces with at least one span matching this filter are retrieved.

#### Min/Max Duration

You can filter the traces by the total time they took in ms.

#### Min/Max Span Count

You can also filter the traces by their span count.&#x20;

#### Time Interval

To apply a time interval, click the "Last 5 min" button next to the "Filters" button. You will see this:

<figure><img src="https://2539979715-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FugegoRCn84wtxrIelgft%2Fuploads%2FdbWPJECZgIfAYOh3cjey%2Fimage.png?alt=media&#x26;token=249a48f4-7378-482b-af69-740eda9b119b" alt=""><figcaption><p>Time interval filtering</p></figcaption></figure>

Here, you can specify your desired time interval. You can specify your start-end times yourself or pick predefined time intervals from the "Quick Selections" section.

{% hint style="info" %}
**Note:** The time interval between the start and the end could be apart at most 24 hours.
{% endhint %}

### Trace Chart

The trace chart allows you to view the distribution of your filtered traces by their dates and durations. While the x-axis is the date, the y-axis is the duration.

<figure><img src="https://2539979715-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FugegoRCn84wtxrIelgft%2Fuploads%2F8IcAj801tCVQlKLd0LT9%2Fimage.png?alt=media&#x26;token=3652d27d-d932-44e6-99b0-4b0010c4aa7d" alt=""><figcaption><p>Trace Chart</p></figcaption></figure>

To view more details (start time, name, duration, span count) about a trace, you can hover on it:

<figure><img src="https://2539979715-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FugegoRCn84wtxrIelgft%2Fuploads%2FDbzNe6qGpUn1p14TCcKO%2Fimage.png?alt=media&#x26;token=4ee93f7b-6954-4971-b869-d34fc7c3b045" alt=""><figcaption><p>Hovering On A Trace</p></figcaption></figure>

### Trace List

Under the trace chart, you can view the filtered traces in a listed format. You can delete them here as well. You can also use the page numbers below to see the remaining traces.

<figure><img src="https://2539979715-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FugegoRCn84wtxrIelgft%2Fuploads%2FUfJWuci85oIm558Gjfk5%2Fimage.png?alt=media&#x26;token=2353de1d-6b32-4a51-b8b8-1eeffdc6372c" alt=""><figcaption><p>Trace List</p></figcaption></figure>

### Trace Details

After you click on a trace (either on the chart or the list), you can view its details (including its call hierarchy and time).

<figure><img src="https://2539979715-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FugegoRCn84wtxrIelgft%2Fuploads%2F1AmgP4m45i73CdcwDbuF%2Fimage.png?alt=media&#x26;token=502e1d3e-15a0-45a2-aac3-22e11946866a" alt=""><figcaption><p>Trace Details</p></figcaption></figure>

Each row represents a trace, whereas the columns represent the time.&#x20;

No matter how long your trace took, the whole hierarchy is always fitted inside your view, so you would not need scrolling/zooming to understand the trace.&#x20;

You can expand/collapse spans by clicking on their "Name" column.

<figure><img src="https://2539979715-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FugegoRCn84wtxrIelgft%2Fuploads%2Fo9BCdZo3WS5w3J4aqgVC%2Fimage.png?alt=media&#x26;token=069ff45b-c381-42bf-9dc1-9a47535cc78e" alt=""><figcaption><p>Collapsed Span</p></figcaption></figure>

You can also hover over a span to see its details, such as:

* Source/target ports
* Path (endpoint)
* Status code
* Request method
* Start/end time

<figure><img src="https://2539979715-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FugegoRCn84wtxrIelgft%2Fuploads%2F0vJcdGYZRiEApE17BXAt%2Fimage.png?alt=media&#x26;token=8108e144-2f9c-4ee2-bdce-e7956442a8c3" alt=""><figcaption><p>Hovering On A Span</p></figcaption></figure>

For more details, you can click on a span:

<figure><img src="https://2539979715-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FugegoRCn84wtxrIelgft%2Fuploads%2FRfnrXh6GDvyveD7ju1lg%2Fimage.png?alt=media&#x26;token=cb92e2f3-6d52-4e66-ab2d-3635bcc03935" alt="" width="563"><figcaption><p>Span Details</p></figcaption></figure>

Here, you can view the span's details, including:

* From/to resources
* From/to IPs
* From/to port numbers
* Start/end times
* Duration
* Path
* Method
* Protocol
* Status code

{% hint style="success" %}
If you require assistance with **Distributed Tracing**, you can join our[ Discord](https://discord.com/invite/9KdnrSUZQg) or send an email to <support@ddosify.com>.
{% endhint %}
