Skip to content

Commit d9d148c

Browse files
committed
[doc] add documentation about tracing
It is a quick overview of tracing and how to enable it in XAPI. Signed-off-by: Guillaume <[email protected]> Signed-off-by: Mathieu Labourier <[email protected]>
1 parent bef6739 commit d9d148c

File tree

1 file changed

+87
-0
lines changed
  • doc/content/toolstack/features/Tracing

1 file changed

+87
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
+++
2+
title = "Tracing"
3+
+++
4+
5+
Tracing is a powerful tool that enables the observation of system behavior across multiple components,
6+
making it particularly useful for debugging and performance analysis in complex environments. By
7+
integrating OpenTelemetry (a standard that unifies OpenTracing and OpenCensus) and the Zipkin v2 protocol,
8+
XAPI enables efficient tracking and visualization of operations across internal and external systems.
9+
This facilitates detailed analysis and improves collaboration between teams.
10+
11+
Tracing is commonly used in high-level applications such as web services. Consequently, less popular or
12+
less web-oriented languages may lack dedicated libraries for distributed tracing. (An OCaml implementation
13+
has been developed specifically for XenAPI.)
14+
15+
# How tracing works in XAPI
16+
17+
## Spans and Trace Context
18+
19+
- A *span* is the core unit of a trace, representing a single operation with a defined start and end time.
20+
Spans can contain sub-spans, which represent child tasks. This helps identify bottlenecks or areas that
21+
can be parallelized.
22+
- A span can contain several contextual elements such as *tags* (key-value pairs),
23+
*events* (time-based data), and *errors*.
24+
- The *TraceContext* HTTP standard defines how trace IDs and span contexts are propagated across systems,
25+
enabling full traceability of operations.
26+
27+
This data makes it possible to create relationships between tasks and generate visualizations such as
28+
architecture diagrams or execution flows. These help in identifying root causes of issues and bottlenecks,
29+
and also assist newcomers in onboarding to the project.
30+
31+
## Configuration
32+
33+
- To enable tracing you need to create an *Observer* object in XAPI. This can be done using the *xe* CLI:
34+
```sh
35+
xe observer-create \
36+
name-label=<name> \
37+
enabled=true \
38+
components=xapi,xenopsd \
39+
endpoints=bugtool,http://<jaeger-ip>:9411/api/v2/spans
40+
```
41+
- **components**: Specify which internal components (e.g., *xapi*, *xenopsd*) should be traced.
42+
More components are expected to be supported in future releases. An experimental *smapi* component
43+
is also available and requires additional configuration (explained below).
44+
45+
- **endpoints**: The observer can collect traces locally in */var/log/dt* or forward them to external
46+
visualization tools such as [Jaeger](https://www.jaegertracing.io/). Currently, only HTTP/S endpoints
47+
are supported, and they also require additional configuration steps (see next section).
48+
49+
- To disable tracing you just need to set *enabled* to false:
50+
```sh
51+
xe observer-param-set uuid=<OBSERVER_UUID> enabled=false
52+
```
53+
54+
### Enabling smapi component
55+
56+
- *smapi* component is currently considered experimental and is filtered by default. To enable it, you must
57+
explicitly configure the following in **xapi.conf**:
58+
```ini
59+
observer-experimental-components=""
60+
```
61+
This tells XAPI that no components are considered as experimental, thereby allowing *smapi* to be traced.
62+
A modification to **xapi.conf** requires a restart of the XAPI toolstack.
63+
64+
### Enabling HTTP/S endpoints
65+
66+
- By default HTTP and HTTPS endpoints are disabled. To enable them, add the following lines to **xapi.conf**:
67+
```ini
68+
observer-endpoint-http-enabled=true
69+
observer-endpoint-https-enabled=true
70+
```
71+
As with enabling *smapi* component, modifying **xapi.conf** requires a restart of the XAPI toolstack.
72+
73+
### Tagging Trace Sessions for Easier Search
74+
75+
To make trace logs easier to locate and analyze, it can be helpful to add custom attributes around the
76+
execution of specific commands. For example:
77+
78+
```sh
79+
# xe observer-param-set uuid=<OBSERVER_UUID> attributes:custom.random=1234
80+
# xe vm-start ...
81+
# xe observer-param-clear uuid=<OBSERVER_UUID> param-name=attributes param-key=custom.random
82+
```
83+
84+
This technique adds a temporary attribute *custom.random=1234* that will appear in the generated trace
85+
spans, making it easier to search for specific activity in trace visualisation tools. It may also be possible
86+
to achieve similar tagging using baggage parameters directly in individual *xe* commands, but this approach
87+
is currently undocumented.

0 commit comments

Comments
 (0)