OpenTelemetry Elasticsearch Instrumentation for Node.js

This module provides automatic instrumentation for @elastic/elasticsearch
and follows otel DB Semantic Conventions.
Installation
npm install opentelemetry-instrumentation-elasticsearch
Usage
For further automatic instrumentation instruction see the @opentelemetry/instrumentation package.
const { NodeTracerProvider } = require('@opentelemetry/node');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const { ElasticsearchInstrumentation } = require('opentelemetry-instrumentation-elasticsearch');
registerInstrumentations({
traceProvider,
instrumentations: [
new ElasticsearchInstrumentation({
})
]
});
Elasticsearch Instrumentation Options
Elasticsearch instrumentation has few options available to choose from. You can set the following (all optional):
Options | Type | Description |
---|
suppressInternalInstrumentation | boolean | Elasticsearch operation use http/https under the hood. Setting this to true will hide the underlying request spans (if instrumented). |
responseHook | ElasticsearchResponseCustomAttributesFunction | Hook called before response is returned, which allows to add custom attributes to span. |
dbStatementSerializer | DbStatementSerializer | Elasticsearch instrumentation will serialize db.statement using the specified function. |
moduleVersionAttributeName | string | If passed, a span attribute will be added to all spans with key of the provided moduleVersionAttributeName and value of the patched module version |
Please make sure dbStatementSerializer
is error proof, as errors are not handled while executing this function.
This extension (and many others) was developed by Aspecto with ❤️