Skip to content

Commit 214fb21

Browse files
authored
Merge pull request #2303 from calebschoepp/observability-sip
Add SIP for configuring and emitting observability
2 parents 72cc025 + 1dc3d5d commit 214fb21

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
title = "SIP 018 - Adding OTel tracing to Spin"
2+
template = "main"
3+
date = "2024-02-27T12:00:00Z"
4+
5+
---
6+
7+
Summary: How to configure OTel support in Spin and add tracing.
8+
9+
10+
11+
Created: February 27, 2024
12+
13+
Updated: April 17, 2024
14+
15+
## Background
16+
17+
[Observability](https://opentelemetry.io/docs/concepts/observability-primer/#what-is-observability) is critical for a great developer experience. Improving the observability of Spin can be broken down into four categories:
18+
19+
1. Runtime observability: Observing the Spin runtime itself e.g. spans and metrics around important parts of the Spin runtime like host components.
20+
2. Trigger observability: Observing the requests made to Spin applications e.g. spans and metrics around the requests made to Spin applications.
21+
3. Component observability: Observing the interaction between composed components e.g having Wasmtime auto-instrument Wasm component graphs to produce spans.
22+
4. Guest observability: Observing code within the guest module e.g. building a host component for WASI Observe.
23+
24+
More detail on these categories can be found [here](https://github.com/fermyon/spin/issues/2293).
25+
26+
## Proposal
27+
28+
This SIP aims to improve the runtime and trigger observability of Spin by emitting tracing. First, it will suggest how OTel tracing in Spin can be configured. Second, it will present guidelines for tracing in Spin.
29+
30+
### Configuring OTel
31+
32+
Spin will conform to the configuration options defined by OTel [here](https://opentelemetry.io/docs/specs/otel/protocol/exporter/) and [here](https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/#general-sdk-configuration).
33+
34+
A user of Spin effectively turns on observability by setting the environment variable `OTEL_EXPORTER_OTLP_ENDPOINT`. This value should be the endpoint of an OTLP compliant collector. They may explicitly turn off observability by setting `OTEL_SDK_DISABLED`.
35+
36+
Under the hood Spin will use the Rust [tracing](https://docs.rs/tracing/0.1.40/tracing/) crate to handle the instrumentation. The user may set `SPIN_OTEL_TRACING_LEVEL` to configure the level of tracing they want to emit to OTel.
37+
38+
In the future we will want to support per-component configuration of observability. For example this might look like the following in a `spin.toml` manifest.
39+
40+
```toml
41+
[component.my-component.tracing]
42+
context_propagation = true # This is all or nothing. If you disable propagation no context will be propagated. By default this is false.
43+
# Opportunity to add fields in the future to
44+
# - Disable tracing for performance reasons
45+
# - Customize span names
46+
# - Add additional metadata
47+
# - More complex allow-listing mechanism for what spans propagate
48+
# - etc.
49+
```
50+
51+
### Adding tracing
52+
53+
As a general rule of thumb we only want to trace behavior that:
54+
55+
- Is fallible.
56+
- Is potentially slow.
57+
- Is not tightly nested under a parent span.
58+
- Is relevant to an end user.
59+
60+
In practice this means tracing most of the triggers and host components.
61+
62+
Where [OTel semantic conventions](https://opentelemetry.io/docs/concepts/semantic-conventions/) exist we should follow them as closely as possible. Where semantic conventions don't exist we should:
63+
64+
- Give the span a name in the form `spin_{crate}.{operation}`.
65+
- Track any relevant arguments as attributes.

0 commit comments

Comments
 (0)