Nodejs applications have different integration methods depending on the scenario. This article describes the detailed steps for integrating Nodejs applications with OpenTelemetry. After integration, you can automatically collect trace information, automatically generate metrics, and use features such as trace search, log search, and more.
Integrate via OpenTelemetry
OpenTelemetry is an observability project under CNCF that aims to provide standardized solutions in the observability domain. It addresses the standardization of data models, collection, processing, and export of observability data, and offers services independent of third-party vendors.
If your application has already integrated the OpenTelemetry SDK, the APMPlus server side can receive data reported by OpenTelemetry. After integrating with APMPlus, you will gain capabilities such as RED metric generation, multidimensional trace search, single trace search, topology generation, and more.
Limits
- APMPlus uses Prometheus as the storage for OpenTelemetry metrics and supports querying metrics using PromQL. For specific applications, see custom dashboard and alert management.
- There are certain restrictions when converting OpenTelemetry metrics to Prometheus metrics:
- Data with the aggregation method set to delta is not supported. Do not modify the default aggregation configuration on the SDK side. Ensure that the aggregation method for SDK-side data is cumulative.
- Each workspace has its own data reporting credentials. To manage and isolate data using workspaces, ensure that the apmplus-opentelemetry-collector component has been upgraded to version v3.1.0 or above.
Automatic integration
APMPlus OpenTelemetry Collector is a data collector developed by APMPlus based on OpenTelemetry Collector. It complies with the Apache 2.0 license, supports the collection of OpenTelemetry monitoring data, and also supports the collection of Prometheus metrics, application monitoring data, and K8s resource metrics.
- Install APM OpenTelemetry Collector.
- Use the VKE cluster component center to perform blank screen installation of the apmplus-opentelemetry-collector component. Go to the VKE cluster interface, select Component Management -> Monitoring, and click the Install button in the upper right corner of the apmplus-opentelemetry-collector component under ... to complete the deployment and management of Apmplus OpenTelemetry Collector.
- Add the instrumentation.apmplus.volcengine.com/inject-nodejs and instrumentation.apmplus.volcengine.com/workspace annotations to the k8s deployment configuration of the service.
- The VKE blank screen configuration is shown below:
- The code example is as follows:
- Restart the application.
OpenTelemetry SDK integration
Use the automatic instrumentation method provided by the community Opentelemetry Node.js SDK to report data. For details, see the community-provided integration documentation. Report data using Opentelemetry automatic instrumentation.
tip
For related information in the official Opentelemetry Node.js documentation, see: getting-started. - Set environment variables and load the instrumentation script using the NODE_OPTIONS and --require mechanisms.