Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
nginx
GitHub Repository: nginx/nginx.org
Path: blob/main/xml/en/docs/ngx_otel_module.xml
1 views
1
<?xml version="1.0"?>
2
3
<!--
4
Copyright (C) Nginx, Inc.
5
-->
6
7
<!DOCTYPE module SYSTEM "../../../dtd/module.dtd">
8
9
<module name="Module ngx_otel_module"
10
link="/en/docs/ngx_otel_module.html"
11
lang="en"
12
rev="4">
13
14
<section id="summary">
15
16
<para>
17
The <literal>ngx_otel_module</literal> module provides
18
<link url="https://opentelemetry.io">OpenTelemetry</link>
19
distributed tracing support.
20
The module supports
21
<link url="https://w3c.github.io/trace-context">W3C</link>
22
context propagation and OTLP/gRPC export protocol.
23
</para>
24
25
<para>
26
The source code of the module is available
27
<link url="https://github.com/nginxinc/nginx-otel">here</link>.
28
Download and install instructions are available
29
<link url="https://github.com/nginxinc/nginx-otel/blob/main/README.md">here</link>.
30
</para>
31
32
<para>
33
The module is also available in a prebuilt
34
<literal>nginx-module-otel</literal>
35
<link doc="../linux_packages.xml" id="dynmodules">package</link>
36
since 1.25.3
37
and in <literal>nginx-plus-module-otel</literal> package
38
as part of our
39
<commercial_version>commercial subscription</commercial_version> since 1.23.4.
40
</para>
41
42
</section>
43
44
45
<section id="example" name="Example Configuration">
46
47
<para>
48
<example>
49
load_module modules/ngx_otel_module.so;
50
51
events {
52
}
53
54
http {
55
56
otel_exporter {
57
endpoint localhost:4317;
58
}
59
60
server {
61
listen 127.0.0.1:8080;
62
63
location / {
64
otel_trace on;
65
otel_trace_context inject;
66
67
proxy_pass http://backend;
68
}
69
}
70
}
71
</example>
72
</para>
73
74
</section>
75
76
77
<section id="directives" name="Directives">
78
79
<directive name="otel_exporter">
80
<syntax block="yes"/>
81
<default/>
82
<context>http</context>
83
84
<para>
85
Specifies OTel data export parameters:
86
87
<list type="tag">
88
89
<tag-name id="endpoint"><literal>
90
endpoint [(http|https)://]host:port;</literal></tag-name>
91
<tag-desc>
92
OTLP/gRPC endpoint that will accept telemetry data.
93
TLS is supported since 0.1.2.
94
</tag-desc>
95
96
<tag-name id="trusted_certificate"><literal>
97
trusted_certificate path;</literal></tag-name>
98
<tag-desc>
99
the CA certificates file in PEM format used to verify TLS endpoint
100
(since 0.1.2).
101
Defaults to OS provided CA bundle.
102
</tag-desc>
103
104
<tag-name id="header"><literal>header name value;</literal></tag-name>
105
<tag-desc>
106
a custom HTTP header to add to telemetry export request (since 0.1.2).
107
</tag-desc>
108
109
<tag-name id="interval"><literal>interval time;</literal></tag-name>
110
<tag-desc>
111
the maximum interval between two exports,
112
by default is <literal>5</literal> seconds.
113
</tag-desc>
114
115
<tag-name id="batch_size"><literal>batch_size number;</literal></tag-name>
116
<tag-desc>
117
the maximum number of spans to be sent in one batch per worker,
118
by default is <literal>512</literal>.
119
</tag-desc>
120
121
<tag-name id="batch_count"><literal>batch_count number;</literal></tag-name>
122
<tag-desc>
123
the number of pending batches per worker,
124
spans exceeding the limit are dropped,
125
by default is <literal>4</literal>.
126
</tag-desc>
127
128
</list>
129
Example:
130
<example>
131
otel_exporter {
132
endpoint https://otel-example.nginx.com:4317;
133
134
header X-API-Token "my-token-value";
135
}
136
</example>
137
</para>
138
139
</directive>
140
141
142
<directive name="otel_service_name">
143
<syntax><value>name</value></syntax>
144
<default>unknown_service:nginx</default>
145
<context>http</context>
146
147
<para>
148
Sets the
149
<link url="https://opentelemetry.io/docs/reference/specification/resource/semantic_conventions/#service"><literal>service.name</literal></link>
150
attribute of the OTel resource.
151
</para>
152
153
</directive>
154
155
156
<directive name="otel_resource_attr">
157
<syntax><value>name</value> <value>value</value></syntax>
158
<default/>
159
<context>http</context>
160
<appeared-in>0.1.2</appeared-in>
161
162
<para>
163
Sets a custom OTel resource attribute.
164
</para>
165
166
</directive>
167
168
169
<directive name="otel_trace">
170
<syntax><literal>on</literal> |
171
<literal>off</literal> |
172
<literal>$variable</literal></syntax>
173
<default>off</default>
174
<context>http</context>
175
<context>server</context>
176
<context>location</context>
177
178
<para>
179
Enables or disables OpenTelemetry tracing.
180
The directive can also be enabled by specifying a variable:
181
<example>
182
split_clients "$otel_trace_id" $ratio_sampler {
183
10% on;
184
* off;
185
}
186
187
server {
188
location / {
189
otel_trace $ratio_sampler;
190
otel_trace_context inject;
191
proxy_pass http://backend;
192
}
193
}
194
</example>
195
</para>
196
197
</directive>
198
199
200
<directive name="otel_trace_context">
201
<syntax><literal>extract</literal> |
202
<literal>inject</literal> |
203
<literal>propagate</literal> |
204
<literal>ignore</literal></syntax>
205
<default>ignore</default>
206
<context>http</context>
207
<context>server</context>
208
<context>location</context>
209
210
<para>
211
Specifies how to propagate
212
<link url="https://www.w3.org/TR/trace-context/#design-overview">traceparent/tracestate</link> headers:
213
214
<list type="tag">
215
216
<tag-name id="extract"><literal>extract</literal></tag-name>
217
<tag-desc>
218
uses an existing trace context from the request,
219
so that the identifiers of
220
a <link id="var_otel_trace_id">trace</link> and
221
the <link id="var_otel_parent_id">parent span</link>
222
are inherited from the incoming request.
223
</tag-desc>
224
225
<tag-name id="inject"><literal>inject</literal></tag-name>
226
<tag-desc>
227
adds a new context to the request, overwriting existing headers, if any.
228
</tag-desc>
229
230
<tag-name id="propagate"><literal>propagate</literal></tag-name>
231
<tag-desc>
232
updates the existing context
233
(combines <link id="extract"/> and <link id="inject"/>).
234
</tag-desc>
235
236
<tag-name id="ignore"><literal>ignore</literal></tag-name>
237
<tag-desc>
238
skips context headers processing.
239
</tag-desc>
240
241
</list>
242
</para>
243
244
</directive>
245
246
247
<directive name="otel_span_name">
248
<syntax><value>name</value></syntax>
249
<default/>
250
<context>http</context>
251
<context>server</context>
252
<context>location</context>
253
254
<para>
255
Defines the name of the OTel
256
<link url="https://opentelemetry.io/docs/concepts/observability-primer/#spans">span</link>.
257
By default, it is a name of the location for a request.
258
The name can contain variables.
259
</para>
260
261
</directive>
262
263
264
<directive name="otel_span_attr">
265
<syntax><value>name</value> <value>value</value></syntax>
266
<default/>
267
<context>http</context>
268
<context>server</context>
269
<context>location</context>
270
271
<para>
272
Adds a custom OTel span attribute.
273
The value can contain variables.
274
</para>
275
276
</directive>
277
278
</section>
279
280
281
<section id="span" name="Default span attributes">
282
283
<para>
284
The following
285
<link url="https://opentelemetry.io/docs/specs/semconv/registry/attributes/http/">span
286
attributes</link>
287
are added automatically:
288
289
<list type="bullet">
290
291
<listitem>
292
<literal>http.method</literal>
293
</listitem>
294
295
<listitem>
296
<literal>http.target</literal>
297
</listitem>
298
299
<listitem>
300
<literal>http.route</literal>
301
</listitem>
302
303
<listitem>
304
<literal>http.scheme</literal>
305
</listitem>
306
307
<listitem>
308
<literal>http.flavor</literal>
309
</listitem>
310
311
<listitem>
312
<literal>http.user_agent</literal>
313
</listitem>
314
315
<listitem>
316
<literal>http.request_content_length</literal>
317
</listitem>
318
319
<listitem>
320
<literal>http.response_content_length</literal>
321
</listitem>
322
323
<listitem>
324
<literal>http.status_code</literal>
325
</listitem>
326
327
<listitem>
328
<literal>net.host.name</literal>
329
</listitem>
330
331
<listitem>
332
<literal>net.host.port</literal>
333
</listitem>
334
335
<listitem>
336
<literal>net.sock.peer.addr</literal>
337
</listitem>
338
339
<listitem>
340
<literal>net.sock.peer.port</literal>
341
</listitem>
342
343
</list>
344
</para>
345
346
</section>
347
348
349
<section id="variables" name="Embedded Variables">
350
351
<para>
352
<list type="tag">
353
354
<tag-name id="var_otel_trace_id"><var>$otel_trace_id</var></tag-name>
355
<tag-desc>
356
the identifier of the trace the current span belongs to,
357
for example, <literal>56552bc4daa3bf39c08362527e1dd6c4</literal>
358
</tag-desc>
359
360
<tag-name id="var_otel_span_id"><var>$otel_span_id</var></tag-name>
361
<tag-desc>
362
the identifier of the current span,
363
for example, <literal>4c0b8531ec38ca59</literal>
364
</tag-desc>
365
366
<tag-name id="var_otel_parent_id"><var>$otel_parent_id</var></tag-name>
367
<tag-desc>
368
the identifier of the parent span,
369
for example, <literal>dc94d281b0f884ea</literal>
370
</tag-desc>
371
372
<tag-name id="var_otel_parent_sampled"><var>$otel_parent_sampled</var></tag-name>
373
<tag-desc>
374
the “<literal>sampled</literal>” flag of the parent span,
375
can be “<literal>1</literal>” or “<literal>0</literal>
376
</tag-desc>
377
378
</list>
379
</para>
380
381
</section>
382
383
</module>
384
385