Skip to content

Allow programmatically import the @aws/aws-distro-opentelemetry-node-autoinstrumentation/register module and customize the NodeSDK #157

@alexandr2110pro

Description

@alexandr2110pro

I want to be able to setup custom components like sampler, span processors, resource detectors and so on.

Manual NodeSDK setup with @opentelemetry/instrumentation-aws-sdk instrumentation doesn't work in bundled (probably, bundled in a very specific way) apps, like NextJS, for example.

See this ticket and these comments specifically:

You guys are doing something else on top of the standard NodeSDK setup that makes @opentelemetry/instrumentation-aws-sdk work in the bundled app.

It would be great if you could wrap everything you do in the register.ts in a fn that accepts the configuration options for the NodeSDK and let us call it programmatically.

Something like that:

import { registerAdotInstrumentation } from '@aws/aws-distro-opentelemetry-node-autoinstrumentation';

registerAdotInstrumentation({
  nodeSdkOptions: {
    instrumentations: [
      new FetchInstrumentation(),
      new HttpInstrumentation(),
      new AwsInstrumentation({
        suppressInternalInstrumentation: true,
      }),
    ],
    sampler: new ParentBasedSampler({
      root: new NextJSSampler({
        // base: new AlwaysOnSampler(),
        base: new TraceIdRatioBasedSampler(0.1),
      }),
    }),
  },
});

Please let me know if you want me to make a PR for this myself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions