signalfx / splunk-otel-js

Splunk Distribution of OpenTelemetry JavaScript
https://docs.splunk.com/Observability/gdi/get-data-in/application/nodejs/get-started.html
Apache License 2.0
23 stars 13 forks source link

Provide bundler/esbuild support and documentation #921

Open davemyers-dev opened 4 months ago

davemyers-dev commented 4 months ago

Feature Enhancement Request

The current library is incredibly difficult to use in a modern Node project that utilizes esbuild for bundling. There is a brief section in the Splunk docs that mentions excluding express from bundling, but it is not sufficient for this library to work when using a bundler.

Several development practices in the library cause runtime errors when combined with esbuild including:

  1. Using relative path imports/requires
  2. Dynamically loading packages https://github.com/signalfx/splunk-otel-js/blob/a191aa3bf28cedbc751bb36ca675319b346e227c/src/instrumentations/index.ts#L228
  3. Providing native binaries

Datadog provides an esbuild plugin to properly utilize their their OTEL trace wrapper library seen here: https://github.com/DataDog/dd-trace-js/blob/master/packages/datadog-esbuild/index.js https://docs.datadoghq.com/tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/#bundling

I would prefer to utilize the Splunk APM specific implementations of AlwaysOn Profiling and Runtime metrics, however, the lack of support, documentation, and community adoption makes this challenging. These challenges are not present when utilizing the OTEL-js libraries or auto-instrumentation directly.

Request: To provide one the following: