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

[Monitor-Opentelemetry] Expose a way to disable metrics (while keeping instrumentation) in instrumentation options #33012

Open
Apokalypt opened this issue Feb 12, 2025 · 2 comments
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Monitor - Exporter Monitor OpenTelemetry Exporter question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@Apokalypt
Copy link

Apokalypt commented Feb 12, 2025

Is your feature request related to a problem? Please describe.
Right now, when we are enabling instrumentation of a SDK through automatic configuration in useAzureMonitor we only have one property to enable/disable instrumentation and metrics. However, in some cases (like ours) we do not need metrics and don't want them as they are generating useless cost

Describe the solution you'd like
In the instrumentation options when calling useAzureMonitor of @azure/monitor-opentelemetry, I would like to have a property like disableMetrics to enable instrumentations but not register metrics, for example :
Image

Describe alternatives you've considered

  • Disable instrumentation in useAzureMonitor and then register manually instrumentation for the library

Additional context
N/A

@github-actions github-actions bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Feb 12, 2025
@jeremymeng jeremymeng added Client This issue points to a problem in the data-plane of the library. Monitor - Exporter Monitor OpenTelemetry Exporter labels Feb 12, 2025
@github-actions github-actions bot removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Feb 12, 2025
@JacksonWeber
Copy link
Member

@Apokalypt between the solution mentioned here: open-telemetry/opentelemetry-js#4487 and disabling the metrics API, it doesn't appear necessary to provide explicit config for this use-case. Please let me know if this doesn't cover your scenario.

@Apokalypt
Copy link
Author

@Apokalypt between the solution mentioned here: open-telemetry/opentelemetry-js#4487 and disabling the metrics API, it doesn't appear necessary to provide explicit config for this use-case. Please let me know if this doesn't cover your scenario.

The solutions provided implies to have access to the SDK instantiation which is not the case when using @azure/monitor-opentelemetry . So, in this case, there is no way to provide a view with an aggregation "Aggregation.drop()" to drop metrics of a specific libraries
Disabling the metrics API completely doesn't seem to work either. Even with that, the instrumentation metrics are received by our service.

Here is a code that you can use to test and reproduce :

const { useAzureMonitor } = require('@azure/monitor-opentelemetry')
const { Resource } = require('@opentelemetry/resources')
const { ATTR_SERVICE_INSTANCE_ID } = require('@opentelemetry/semantic-conventions/incubating')
const { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION } = require('@opentelemetry/semantic-conventions')

useAzureMonitor({
    azureMonitorExporterOptions: { key: process.env.APPLICATIONINSIGHTS_CONNECTION_STRING },
    resource: new Resource({
        [ATTR_SERVICE_NAME]: 'test-metrics-express',
        [ATTR_SERVICE_VERSION]: '1.0.0',
        [ATTR_SERVICE_INSTANCE_ID]: process.env.WEBSITE_INSTANCE_ID
    }),

    instrumentationOptions: {
        http: { enabled: true },

        azureSdk: { enabled: false },
        mongoDb: { enabled: false },
        redis4: { enabled: false },
        mySql: { enabled: false },
        redis: { enabled: false },
        bunyan: { enabled: false },
        winston: { enabled: false },
        postgreSql: { enabled: false }
    },
    browserSdkLoaderOptions: { enabled: false },

    samplingRatio: 1,

    enableLiveMetrics: false,
    enableStandardMetrics: false,
    enableTraceBasedSamplingForLogs: true
})

const { metrics } = require('@opentelemetry/api')
metrics.disable()

const express = require('express')

const app = express()
    .disable('x-powered-by')

app.get('/', (req, res) => {
    res.status(200).send({ })
})

app.listen(3000, () => {
    console.debug('Server started on port 3000')
})

And in the table customMetrics we can see :
Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Monitor - Exporter Monitor OpenTelemetry Exporter question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

No branches or pull requests

3 participants