Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add metrics support to auto-instrumentations-node #2527

Open
pavolloffay opened this issue Nov 15, 2024 · 2 comments
Open

Add metrics support to auto-instrumentations-node #2527

pavolloffay opened this issue Nov 15, 2024 · 2 comments

Comments

@pavolloffay
Copy link
Member

Is your feature request related to a problem? Please describe

The OTEL operator uses auto-instrumentations-node, however the dependency does not initialize metrics exporters (otlp and Prometheus) https://github.com/open-telemetry/opentelemetry-operator/blob/main/autoinstrumentation/nodejs/src/autoinstrumentation.ts#L33

It would be great to move this logic to this project so that the OTEL operator can depend only on auto-instrumentations-node and use the supported way to initialize the instrumentation env NODE_OPTIONS="--require @opentelemetry/auto-instrumentations-node/register"

This ticket is related to open-telemetry/opentelemetry-operator#3465

Describe the solution you'd like to see

Add the following dependencies to uto-instrumentations-node or any transitive dependency e.g. sdk-node

        "@opentelemetry/exporter-metrics-otlp-grpc": "0.54.0",
        "@opentelemetry/exporter-prometheus": "0.54.0"

and initialize the metrics exporter

function getMetricReader() {
    switch (process.env.OTEL_METRICS_EXPORTER) {
        case undefined:
        case '':
        case 'otlp':
            diag.info('using otel metrics exporter');
            return new PeriodicExportingMetricReader({
                exporter: new OTLPMetricExporter(),
            });
        case 'prometheus':
            diag.info('using prometheus metrics exporter');
            return new PrometheusExporter({});
        case 'none':
            diag.info('disabling metrics reader');
            return undefined;
        default:
            throw Error(`no valid option for OTEL_METRICS_EXPORTER: ${process.env.OTEL_METRICS_EXPORTER}`)
    }
}

Describe alternatives you've considered

Additional context

open-telemetry/opentelemetry-operator#3465

@pavolloffay
Copy link
Member Author

cc) @JamieDanielson

@JamieDanielson
Copy link
Member

It looks like this should be handled when we add the ability to use environment variables with the Node SDK for metrics. After that we should be able to cleanup some of the code in the operator and allow the auto-instrumentations package to handle a lot more of the work with less duplication of code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants