Skip to content

Commit c21f555

Browse files
committed
Updated OpenTelemetry Dynamic module.
1 parent 0e1197d commit c21f555

File tree

1 file changed

+107
-167
lines changed

1 file changed

+107
-167
lines changed

content/nginx/admin-guide/dynamic-modules/opentelemetry.md

Lines changed: 107 additions & 167 deletions
Original file line numberDiff line numberDiff line change
@@ -9,242 +9,181 @@ type:
99
- how-to
1010
---
1111

12-
<span id="overview"></span>
13-
## Module Overview
12+
## Overview {#overview}
1413

15-
The module provides [OpenTelemetry](https://opentelemetry.io/) distributed tracing support. The module supports [W3C](https://w3c.github.io/trace-context/) context propagation and OTLP/gRPC export protocol.
14+
[OpenTelemetry](https://opentelemetry.io/) (OTel) is an observability framework for monitoring, tracing, troubleshooting, and optimizing applications. OTel enables the collection of telemetry data from a deployed application stack.
1615

17-
{{< note >}} the code of NGINX OpenTelemetry module is open source since [NGINX Open Source](https://nginx.org) 1.25.2 and NGINX Plus [Release 30]({{< ref "nginx/releases.md#r30" >}}). The source code is available on [GitHub](https://github.com/nginxinc/nginx-otel).{{< /note >}}
16+
The `nginx-plus-module-otel` module is NGINX-authored dynamic module that enables NGINX Plus to send telemetry data to an OTel collector. The module supports [W3C](https://w3c.github.io/trace-context/) trace context propagation, OpenTelemetry Protocol (OTLP)/gRPC trace exports, and offers several advantages over existing OTel modules including:
1817

18+
- Enhanced performance: other OTel implementations can reduce request processing by up to 50%, while `nginx-plus-module-otel` minimizes this impact to just 10-15%.
1919

20-
<span id="install"></span>
21-
## Installation
20+
- Simplified provisioning through NGINX configuration file.
21+
22+
- Dynamic, variable-based control of trace parameters with cookies, tokens, and variables. See [Ratio-based Tracing](#example) example for details.
23+
24+
- Dynamic control of sampling parameters via the [NGINX Plus API]({{< ref "/nginx/admin-guide/monitoring/live-activity-monitoring.md#using-the-rest-api" >}}) and [key-value storage]({{< ref "/nginx/admin-guide/security-controls/denylisting-ip-addresses.md" >}}).
25+
26+
The repository can be found on [GitHub](https://github.com/nginxinc/nginx-otel). The documentation can be found on [nginx.org](https://nginx.org/en/docs/ngx_otel_module.html).
27+
28+
29+
## Installation {#install}
30+
31+
Similar to [NGINX Plus]({{< ref "/nginx/admin-guide/installing-nginx/installing-nginx-plus.md" >}}), prebuilt packages of the `nginx-plus-module-otel` module can can be installed directly from the official repository for different distributions. Before installation you will need to add NGINX Plus package repositories for your distribution and update the repository metadata.
2232

2333
1. Check the [Technical Specifications]({{< ref "nginx/technical-specs.md" >}}) page to verify that the module is supported by your operating system.
2434

25-
2. Install the OpenTelemetry module package `nginx-plus-module-otel`.
35+
{{< note >}} The OpenTelemetry module cannot be installed on Amazon Linux 2 LTS and SLES 15 SP5+. {{< /note >}}
2636

27-
For CentOS, Oracle Linux, and RHEL:
37+
2. Make sure you have the latest version of NGINX Plus or you have upgraded NGINX Plus to the latest version. In Terminal, run the command:
2838

2939
```shell
30-
yum install nginx-plus-module-otel
40+
nginx -v
3141
```
3242

33-
For Amazon Linux 2023, AlmaLinux, Rocky Linux:
43+
Expected output of the command:
3444

3545
```shell
36-
dnf install nginx-plus-module-otel
46+
nginx version: nginx/1.27.4 (nginx-plus-r34)
3747
```
3848

39-
For Debian and Ubuntu:
49+
3. Make sure you have installed dependencies required for your operating system.
50+
51+
For Amazon Linux 2023, AlmaLinux, CentOS, Oracle Linux, RHEL, and Rocky Linux:
4052

4153
```shell
42-
apt-get install nginx-plus-module-otel
54+
sudo dnf update
55+
sudo dnf install ca-certificates
56+
sudo dnf update-ca-certificates #use if ca-certificates are installed
4357
```
4458

45-
For SLES:
59+
For Debian:
4660

4761
```shell
48-
zypper install nginx-plus-module-otel
62+
sudo apt update
63+
sudo apt install apt-transport-https lsb-release ca-certificates wget gnupg2 debian-archive-keyring
4964
```
5065

51-
For Alpine:
52-
5366
```shell
54-
apk add nginx-plus-module-otel
67+
wget -qO - https://cs.nginx.com/static/keys/nginx_signing.key \
68+
| gpg --dearmor \
69+
| sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null
5570
```
5671

57-
For FreeBSD:
72+
For Ubuntu:
5873

5974
```shell
60-
pkg install nginx-plus-module-otel
75+
sudo apt update
76+
sudo apt install apt-transport-https lsb-release ca-certificates wget gnupg2 ubuntu-keyring
6177
```
6278

63-
{{< note >}} the OpenTelemetry module cannot be installed on RHEL/Oracle Linux/AlmaLinux/Rocky Linux 7, Ubuntu 18.04, and Amazon Linux 2. {{< /note >}}
64-
65-
66-
<span id="configure"></span>
67-
68-
## Configuration
69-
70-
After installation you will need to enable and configure the module in NGINX Plus configuration file `nginx.conf`.
71-
72-
1. Enable dynamic loading of the module with the [`load_module`](https://nginx.org/en/docs/ngx_core_module.html#load_module) directive specified in the top-level (“`main`”) context:
73-
74-
```nginx
75-
load_module modules/ngx_otel_module.so;
79+
```shell
80+
printf "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
81+
https://pkgs.nginx.com/plus/ubuntu `lsb_release -cs` nginx-plus\n" \
82+
| sudo tee /etc/apt/sources.list.d/nginx-plus.list
7683
```
7784

78-
2. Test the configuration and reload NGINX Plus to enable the module:
85+
For Alpine:
7986

8087
```shell
81-
nginx -t && nginx -s reload
88+
sudo wget -O /etc/apk/keys/nginx_signing.rsa.pub https://cs.nginx.com/static/keys/nginx_signing.rsa.pub
8289
```
8390

91+
For FreeBSD:
8492

85-
<span id="directives"></span>
86-
## Module directives
87-
88-
<span id="otel_exporter"></span>
89-
### `otel_exporter`
90-
91-
**Syntax:** `otel_exporter { ... }`;
92-
93-
**Default:** &mdash;
94-
95-
**Context:** [`http`](https://nginx.org/en/docs/http/ngx_http_core_module.html#http)
96-
97-
Specifies OTel data export parameters:
98-
99-
- `endpoint` &mdash; the address of OTLP/gRPC endpoint that will accept telemetry data.
100-
- `interval` &mdash; the maximum interval between two exports, by default is 5 seconds.
101-
- `batch_size` &mdash; the maximum number of spans to be sent in one batch per worker, by default is `512`.
102-
- `batch_count` &mdash; the number of pending batches per worker, spans exceeding the limit are dropped, by default is `4`.
103-
104-
**Example:**
105-
106-
```nginx
107-
otel_exporter {
108-
endpoint localhost:4317;
109-
interval 5s;
110-
batch_size 512;
111-
batch_count 4;
112-
}
113-
```
114-
115-
<br>
116-
117-
<span id="otel_service_name"></span>
118-
### `otel_service_name`
119-
120-
**Syntax:** `otel_service_name` <i>name</i>;
121-
122-
**Default:** `otel_service_name` <i>unknown_service:nginx</i>;
123-
124-
**Context:** [`http`](https://nginx.org/en/docs/http/ngx_http_core_module.html#http)
125-
126-
Sets the [“service.name”](https://opentelemetry.io/docs/specs/otel/resource/semantic_conventions/#service) attribute of the OTel resource.
127-
<br>
128-
<br>
129-
130-
<span id="otel_trace"></span>
131-
### `otel_trace`
132-
133-
**Syntax:** `otel_trace` <i>on</i> | <i>off</i> | <i>$variable</i>;
134-
135-
**Default:** `otel_trace` <i>off</i>;
93+
```shell
94+
sudo pkg update
95+
sudo pkg install ca_root_nss
96+
```
13697

137-
**Context:** [`http`](https://nginx.org/en/docs/http/ngx_http_core_module.html#http), [`server`](https://nginx.org/en/docs/http/ngx_http_core_module.html#server), [`location`](https://nginx.org/en/docs/http/ngx_http_core_module.html#location)
98+
3. Make sure you have obtained the **nginx-repo.crt** and **nginx-repo.key** files from MyF5 and put them to the **/etc/ssl/nginx/** directory. These files are required for accessing the NGINX Plus repository:
13899

139-
Enables or disables OpenTelemetry tracing. The directive can also be enabled by specifying a variable.
100+
```shell
101+
sudo cp nginx-repo.crt /etc/ssl/nginx/
102+
sudo cp nginx-repo.key /etc/ssl/nginx/
103+
```
140104

141-
**Example:**
105+
For Alpine, upload **nginx-repo.crt** to **/etc/apk/cert.pem** and **nginx-repo.key** to **/etc/apk/cert.key**. Ensure these files contain only the specific key and certificate as Alpine Linux does not support mixing client certificates for multiple repositories.
142106

143-
```nginx
144-
split_clients "$otel_trace_id" $ratio_sampler {
145-
10% on;
146-
* off;
147-
}
107+
4. Make sure your package management system is configured to pull from NGINX Plus repository. See [Installing NGINX Plus]({{< ref "/nginx/admin-guide/installing-nginx/installing-nginx-plus.md" >}}) for details.
148108

149-
server {
150-
location / {
151-
otel_trace $ratio_sampler;
152-
otel_trace_context inject;
153-
proxy_pass http://backend;
154-
}
155-
}
156-
```
109+
4. Update the repository information and install the package. In Terminal, run the appropriate command for your operating system.
157110

158-
<br>
111+
For CentOS, Oracle Linux, and RHEL:
159112

160-
<span id="otel_trace_context"></span>
161-
### `otel_trace_context`
113+
```shell
114+
sudo yum update
115+
sudo yum install nginx-plus-module-otel
116+
```
162117

163-
**Syntax:** `otel_trace_context` <i>extract</i> | <i>inject</i> | <i>propagate</i> | <i>ignore</i>;
118+
For Amazon Linux 2023, AlmaLinux, Rocky Linux:
164119

165-
**Default:** `otel_trace_context` <i>ignore</i>;
120+
```shell
121+
sudo dnf update
122+
sudo dnf install nginx-plus-module-otel
123+
```
166124

167-
**Context:** [`http`](https://nginx.org/en/docs/http/ngx_http_core_module.html#http), [`server`](https://nginx.org/en/docs/http/ngx_http_core_module.html#server), [`location`](https://nginx.org/en/docs/http/ngx_http_core_module.html#location)
125+
For Debian and Ubuntu:
168126

169-
Specifies how to propagate [traceparent/tracestate](https://www.w3.org/TR/trace-context/#design-overview) headers:
127+
```shell
128+
sudo apt update
129+
sudo apt install nginx-plus-module-otel
130+
```
170131

171-
- `extract` &mdash; uses an existing trace context from the request, so that the identifiers of a [trace](#var_otel_trace_id) and the [parent span](#var_otel_parent_id) are inherited from the incoming request.
172-
- `inject` &mdash; adds a new context to the request, overwriting existing headers, if any.
173-
- `propagate` &mdash; updates the existing context (combines `extract` and `inject`).
174-
- `ignore` &mdash; skips context headers processing.
175-
<br>
132+
For Alpine:
176133

177-
<br>
134+
```shell
135+
sudo apk update
136+
sudo apk add nginx-plus-module-otel
137+
```
178138

179-
<span id="otel_span_name"></span>
180-
### `otel_span_name`
139+
For FreeBSD:
181140

182-
**Syntax:** `otel_span_name` <i>name</i>;
141+
```shell
142+
sudo pkg update
143+
sudo pkg install nginx-plus-module-otel
144+
```
183145

184-
**Default:** &mdash;
146+
The module will be installed into `/usr/local/nginx` directory.
185147

186-
**Context:** [`http`](https://nginx.org/en/docs/http/ngx_http_core_module.html#http), [`server`](https://nginx.org/en/docs/http/ngx_http_core_module.html#server), [`location`](https://nginx.org/en/docs/http/ngx_http_core_module.html#location)
148+
6. Copy the `ngx_otel_module.so` dynamic module binary to `/usr/local/nginx/modules`.
187149

188-
Defines the name of the OTel [span](https://opentelemetry.io/docs/concepts/observability-primer/#spans). By default, it is a name of the location for a request. The name can contain variables.
189-
<br>
190-
<br>
150+
7. Enable dynamic loading of the module. Open the NGINX Plus configuration file, `nginx.conf` in a text editor, and specify the [`load_module`](https://nginx.org/en/docs/ngx_core_module.html#load_module) directive on the top-level (“`main`”) context:
191151

192-
<span id="otel_span_attr"></span>
193-
### `otel_span_attr`
152+
```nginx
153+
load_module modules/ngx_otel_module.so;
194154
195-
**Syntax:** `otel_span_attr` <i>name</i> <i>value</i>;
155+
http {
156+
#...
157+
}
158+
```
196159

197-
**Default:** &mdash;
160+
3. Save the configuration file.
198161

199-
**Context:** [`http`](https://nginx.org/en/docs/http/ngx_http_core_module.html#http), [`server`](https://nginx.org/en/docs/http/ngx_http_core_module.html#server), [`location`](https://nginx.org/en/docs/http/ngx_http_core_module.html#location)
162+
4. Test and reload NGINX Plus configuration to enable the module. In Terminal, type-in the command:
200163

201-
Adds a custom OTel span attribute. The value can contain variables.
202-
<br>
164+
```shell
165+
nginx -t && nginx -s reload
166+
```
203167

204168

205-
<span id="span_attributes"></span>
206-
## Default span attributes
169+
## Configuration {#configure}
207170

208-
The following [span attributes](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/http.md) are added automatically:
171+
For a complete list of directives, embedded variables, default span attributes, refer to the `ngx_otel_module` official documentation.
209172

210-
- `http.method`
211-
- `http.target`
212-
- `http.route`
213-
- `http.scheme`
214-
- `http.flavor`
215-
- `http.user_agent`
216-
- `http.request_content_length`
217-
- `http.response_content_length`
218-
- `http.status_code`
219-
- `net.host.name`
220-
- `net.host.port`
221-
- `net.sock.peer.addr`
222-
- `net.sock.peer.port`
173+
List of directives:
223174

175+
[`https://nginx.org/en/docs/ngx_otel_module.html#directives`](https://nginx.org/en/docs/ngx_otel_module.html#directives)
224176

225-
<span id="variables"></span>
226-
## Module variables
177+
List of variables:
227178

228-
<span id="var_otel_trace_id"></span>
229-
### `$otel_trace_id`
230-
the identifier of the trace the current span belongs to, for example, `56552bc4daa3bf39c08362527e1dd6c4`
179+
[`https://nginx.org/en/docs/ngx_otel_module.html#variables`](https://nginx.org/en/docs/ngx_otel_module.html#variables)
231180

232-
<span id="var_otel_span_id"></span>
233-
### `$otel_span_id`
234-
the identifier of the current span, for example, `4c0b8531ec38ca59`
181+
Default span attributes:
235182

236-
<span id="var_otel_parent_id"></span>
237-
### `$otel_parent_id`
238-
the identifier of the parent span, for example, `dc94d281b0f884ea`
183+
[`https://nginx.org/en/docs/ngx_otel_module.html#span`](https://nginx.org/en/docs/ngx_otel_module.html#span)
239184

240-
<span id="var_otel_parent_sampled"></span>
241-
### `$otel_parent_sampled`
242-
the `sampled` flag of the parent span, can be `1` or `0`
243-
<br>
244-
<br>
245185

246-
<span id="example"></span>
247-
## Usage examples
186+
## Usage examples {#example}
248187

249188
### Simple Tracing
250189

@@ -303,10 +242,11 @@ http {
303242
}
304243
```
305244

306-
<span id="info"></span>
307-
## More Info
245+
## More Info {#info}
246+
247+
- [GitHub Repository for the NGINX Native OpenTelemetry Module](https://github.com/nginxinc/nginx-otel)
308248

309-
- [NGINX OpenTelemetry module on GitHub](https://github.com/nginxinc/nginx-otel)
249+
- [Official Documentation for the NGINX Native OpenTelemetry Module](https://nginx.org/en/docs/ngx_otel_module.html)
310250

311251
- [NGINX Dynamic Modules]({{< ref "dynamic-modules.md" >}})
312252

0 commit comments

Comments
 (0)