Skip to content

Commit

Permalink
feat(auto-instrumentations-node): Expose getting resource detectors (#…
Browse files Browse the repository at this point in the history
…1772)

* feat(auto-instrumentations-node): Expose getting resource detectors

The auto instrumentation package provides users with a very easy way to
instrument their application, either from the commandline or
programatically. Users wishing the configure these instrumentations can also
call `getNodeAutoInstrumentations`.

This commit also exposes `getResourceDetectorsFromEnv`, so that users
configuring or somehow wishing to change the easy to use autoinstrumentation
entrypoint can also use the preconfigured resource detectors. Since the
autoinstrumentation package sets its exports, this function was previously
inaccessible.

Usage can look like this:

```js
const { getNodeAutoInstrumentations, getResourceDetectorsFromEnv } = require('@opentelemetry/auto-instrumentations-node');
const opentelemetry = require('@opentelemetry/sdk-node');

const sdk = new opentelemetry.NodeSDK({
  instrumentations: getNodeAutoInstrumentations({
    '@opentelemetry/instrumentation-fs': { enabled: false },
  }),
  resourceDetectors: getResourceDetectorsFromEnv(),
});

// use the sdk
```

Workarounds can be found [elsewhere in the opentelemetry repos](https://github.com/open-telemetry/opentelemetry-demo/blob/855bde3588b0fe85e500bec185dc2f311b15f98a/src/paymentservice/opentelemetry.js#L28-L38).
These can be fixed once a release is made.

Resolves #1531.

* style: Align indentation

---------

Co-authored-by: Amir Blum <amirgiraffe@gmail.com>
  • Loading branch information
Zirak and blumamir authored Nov 8, 2023
1 parent adbe86d commit 89f07d1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion metapackages/auto-instrumentations-node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@
* limitations under the License.
*/

export { getNodeAutoInstrumentations, InstrumentationConfigMap } from './utils';
export {
getNodeAutoInstrumentations,
getResourceDetectorsFromEnv,
InstrumentationConfigMap,
} from './utils';

0 comments on commit 89f07d1

Please sign in to comment.