You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/languages/node.md
+42Lines changed: 42 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -278,3 +278,45 @@ This is useful when the function is expected to receive large amounts of JSON da
278
278
MAX_JSON_SIZE: '5mb'
279
279
```
280
280
281
+
## OpenTelemetry zero-code instrumentation
282
+
283
+
Using [OpenTelemetry zero-code instrumentation](https://opentelemetry.io/docs/zero-code/js/) for Node.js functions requires some minor modifications to the existing Node.js templates.
284
+
285
+
There are two ways to [customise a template](/cli/templates/#how-to-customise-a-template):
286
+
287
+
- Fork the template repository and modify the template. Recommended method that allows for distribution and reuse of the template.
288
+
- Pull the template and apply patches directly in the `./template/<language_name>` directory. Good for quick iteration and experimentation with template modifications. The modified template can not be shared and reused. Changes may get overwritten when pulling templates again.
289
+
290
+
Add the required packages for zero code instrumentation to the template `package.json`:
- `OTEL_SERVICE_NAME`sets the name of the service associated with the telemetry and is used to identify telemetry for a specific function. It can be set to any value you want be we recommend using the clear function identifier `<fn-name>.<fn-namespace>`.
317
+
- `OTEL_TRACES_EXPORTER`specifies which tracer exporter to use. In this example traces are exported to `console` (stdout) and with `otlp`. The `otlp` option tells the instrumentation module to send the traces to an endpoint that accepts OTLP via gRPC.
318
+
- setting `OTEL_METRICS_EXPORTER` and `OTEL_LOGS_EXPORTER` to `none` we disable the metrics and logs exporters. You can enable them if desired.
319
+
- `OTEL_EXPORTER_OTLP_ENDPOINT`sets the endpoint where telemetry is exported to.
320
+
- The `NODE_OPTIONS` environment variable needs to have the value `--require @opentelemetry/auto-instrumentations-node/register` to register and initialize the auto instrumentation module.
321
+
322
+
To see the full range of configuration options, see [Module Configuration](https://opentelemetry.io/docs/zero-code/js/configuration/).
Using [OpenTelemetry zero-code instrumentation](https://opentelemetry.io/docs/zero-code/python/) for python functions requires some minor modifications to the existing Python templates.
391
+
392
+
There are two ways to [customise a template](/cli/templates/#how-to-customise-a-template):
393
+
394
+
- Fork the template repository and modify the template. Recommended method that allows for distribution and reuse of the template.
395
+
- Pull the template and apply patches directly in the `./template/<language_name>` directory. Good for quick iteration and experimentation with template modifications. The modified template can not be shared and reused. Changes may get overwritten when pulling templates again.
396
+
397
+
Add the required packages for auto instrumentation to the `requirements.txt` file of the template:
398
+
399
+
```
400
+
opentelemetry-distro
401
+
opentelemetry-exporter-otlp
402
+
```
403
+
404
+
Update the Dockerfile to run the bootstrap command after the the template and function packages have been installed:
405
+
406
+
```diff
407
+
# Build the function directory and install any user-specified components
408
+
USER app
409
+
410
+
RUN mkdir -p function
411
+
RUN touch ./function/__init__.py
412
+
WORKDIR /home/app/function/
413
+
COPY --chown=app:app function/requirements.txt .
414
+
RUN pip install --no-cache-dir --user -r requirements.txt
415
+
+ RUN opentelemetry-bootstrap -a install
416
+
```
417
+
418
+
The `opentelemetry-bootstrap -a install` command reads through the list of packages installed in your active site-packages folder, and installs the corresponding instrumentation libraries for these packages, if applicable. The OpenTelemetry Python agent uses [monkey patching](https://stackoverflow.com/questions/5626193/what-is-monkey-patching) to modify functions in these libraries at runtime.
419
+
420
+
421
+
Update the fprocess ENV in the Dockerfile to start the OpenTelemetry agent:
-`OTEL_SERVICE_NAME` sets the name of the service associated with the telemetry and is used to identify telemetry for a specific function. It can be set to any value you want be we recommend using the clear function identifier `<fn-name>.<fn-namespace>`.
450
+
-`OTEL_TRACES_EXPORTER` specifies which tracer exporter to use. In this example traces are exported to `console` (stdout) and with `otlp`. The `otlp` option tells `opentelemetry-instrument` to send the traces to an endpoint that accepts OTLP via gRPC.
451
+
- setting `OTEL_METRICS_EXPORTER` and `OTEL_LOGS_EXPORTER` to `none` we disable the metrics and logs exporters. You can enable them if desired.
452
+
-`OTEL_EXPORTER_OTLP_ENDPOINT` sets the endpoint where telemetry is exported to.
453
+
454
+
To see the full range of configuration options, see [Agent Configuration](https://opentelemetry.io/docs/zero-code/python/configuration/)
0 commit comments