otel-instrumentation-http-plus
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

OpenTelemetry HTTP Instrumentation Plus (Javascript/Node.js)

Build Status NPM Version License

NPM package which provides advanced automatic instrumentation for Node.js http and https modules on top of OpenTelemetry @opentelemetry/instrumentation-http instrumentation module.

Installation

To install the package, you can use NPM (or Yarn):

npm install --save otel-instrumentation-http-plus

Note: Requires @opentelemetry/api version 1.0.0+ and @opentelemetry/instrumentation-http version 0.30.0+ installed.

Usage

You need to import/require HttpPlusInstrumentation first and then register HttpPlusInstrumentation instance through registerInstrumentations method provided by the instrumentation API ('@opentelemetry/instrumentation') as shown below:

const { HttpPlusInstrumentation } = require('otel-instrumentation-http-plus');
const {
  ConsoleSpanExporter,
  NodeTracerProvider,
  SimpleSpanProcessor,
} = require('@opentelemetry/sdk-trace-node');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');

const provider = new NodeTracerProvider();

provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
provider.register();

registerInstrumentations({
  instrumentations: [new HttpPlusInstrumentation({
      // Put options here. See "Configuration" section below for more details
  })],
});

Configuration

In addition to base OpenTelemetry HTTP instrumentation options here, OpenTelemetry HTTP Instrumentation Plus also provides the following options to configure:

Options Type Default Value Description
captureRequestBody boolean false Enables capturing HTTP request body
maxRequestBodySize number 4096 (4 KB) Sets maximum size limit for HTTP request body to be captured
captureResponseBody boolean false Enables capturing HTTP response body
maxResponseBodySize number 4096 (4 KB) Sets maximum size limit for HTTP response body to be captured
maxResponseBodySize number 4096 (4 KB) Sets maximum size limit for HTTP response body to be captured
traceNetworkOperations boolean false Enables tracing network timings by creating spans for the following traced network operations
- DNS Lookup
- TCP Connect
- TLS Handshake
- TTFB (Time To First Byte)
- Content Transfer
traceNetworkOperations boolean false Enables tracing network timings by creating spans for the following traced network operations
- DNS Lookup
- TCP Connect
- TLS Handshake
- TTFB (Time To First Byte)
- Content Transfer
requestBodyMaskHook HttpRequestBodyMaskFunction - Function for masking traced HTTP request body (for ex. deleting or hiding sensitive fields)
responseBodyMaskHook HttpResponseBodyMaskFunction - Function for masking traced HTTP response body (for ex. deleting or hiding sensitive fields)

Examples

You can find examples under examples directory. To be able to run the example, you can run the following command:

npm run example

Roadmap

  • Support masking for captured HTTP request and/or response bodies by configured ignored keys (without custom function implementation)

Issues and Feedback

Issues Closed issues

Please use GitHub Issues for any bug report, feature request and support.

Contribution

Pull requests Closed pull requests Contributors

If you would like to contribute, please

  • Fork the repository on GitHub and clone your fork.
  • Create a branch for your changes and make your changes on it.
  • Send a pull request by explaining clearly what is your contribution.

Tip: Please check the existing pull requests for similar contributions and consider submit an issue to discuss the proposed feature before writing code.

License

Licensed under MIT License.

Package Sidebar

Install

npm i otel-instrumentation-http-plus

Weekly Downloads

0

Version

0.0.4

License

MIT

Unpacked Size

26.3 kB

Total Files

6

Last publish

Collaborators

  • serkan-ozal