Elasticsearch

This feature requires AppSignal for Node.js version 3.7.2 or higher.
This feature requires Elasticsearch Node.js client version 8.15.0 or higher.

Elasticsearch is a popular search and analytics engine. The AppSignal for Node.js integration for Elasticsearch provides automatic instrumentation for the Elasticsearch Node.js client.

Installation

The Elasticsearch Node.js client includes instrumentation via OpenTelemetry. It will automatically report data to the AppSignal for Node.js package. No additional setup is required to instrument Elasticsearch in your application.

Features

The built-in instrumentation captures spans for search queries, index operations, and other interactions with your Elasticsearch cluster. The integration will send AppSignal spans representing the execution time of each Elasticsearch API call with information about the operation.

Configuration

The automatic instrumentation can be disabled starting from version 9.x of @elastic/elasticsearch. If you are using version 8.x of @elastic/elasticsearch make sure you are using @elastic/transport version 8.10.0 or higher.

You can disable the instrumentation of Elasticsearch by:

  • setting an environment variable;

    Shell
    OTEL_ELASTICSEARCH_ENABLED=false
  • using a custom Transport.

    app.ts
    import { Transport, TransportRequestOptions, TransportRequestParams, } from "@elastic/transport"; class CustomTransport extends Transport { async request( params: TransportRequestParams, options: TransportRequestOptions = {} ): Promise<any> { options.openTelemetry = { enabled: false }; return super.request(params, options); } } const client = new Client({ /* your client config... */ Transport: CustomTransport, });

You can also leave the instrumentation enabled and disable it for a single API call by passing a custom TransportRequestOptions object as the second argument to any API call:

typescript
const response = await client.search({ ... }, { openTelemetry: { enabled: false }, });