microsoft / ApplicationInsights-node.js

Microsoft Application Insights SDK for Node.js
MIT License
320 stars 138 forks source link

Duplicate/Invalid metric errors when starting useAzureMonitor #1218

Open pedro37 opened 9 months ago

pedro37 commented 9 months ago

I add config as per README and get duplicate errors in the config am I missing something?


import { useAzureMonitor } from 'applicationinsights';
const config= {
      azureMonitorExporterOptions: {
        connectionString: myConnectionString,
      },
      samplingRatio: 1,
      enableAutoCollectExceptions: true,
      enableAutoCollectStandardMetrics: true,
      enableAutoCollectPerformance: true,
      instrumentationOptions: {
        azureSdk: { enabled: true },
        http: { enabled: true },
        redis: { enabled: true }
      },
      logInstrumentationOptions: {
        bunyan: { enabled: true},
        winston: { enabled: true},
      },
      extendedMetrics: {
        gc: true,
        heap: true,
        loop: true
      }
    };
    useAzureMonitor(config);`

ApplicationInsights:Invalid metric name: "Request Duration". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "\Memory\Available Bytes". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "Throttle Count". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "Request Failure Count". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "Exception Count". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "\ASP.NET Applications(??APP_W3SVC_PROC??)\Requests/Sec". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "Request Success Count". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "Retry Count". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "Throttle Count". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "\ASP.NET Applications(??APP_W3SVC_PROC??)\Request Execution Time". The metric name should be a ASCII string with a length no greater than 255 characters. []
'Module @azure/core-tracing has been loaded before @azure/opentelemetry-instrumentation-azure-sdk so it might not work, please initialize it before requiring @azure/core-tracing'
ApplicationInsights:Invalid metric name: "Request Failure Count". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "Exception Count". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "Throttle Count". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "\ASP.NET Applications(??APP_W3SVC_PROC??)\Request Execution Time". The metric name should be a ASCII string with a length no greater than 255 characters. []
'Module @azure/core-tracing has been loaded before @azure/opentelemetry-instrumentation-azure-sdk so it might not work, please initialize it before requiring @azure/core-tracing'
ApplicationInsights:Invalid metric name: "Request Failure Count". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "Exception Count". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "Throttle Count". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "Request Duration". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "\Processor(_Total)\% Processor Time". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "\Process(??APP_WIN32_PROC??)\Private Bytes". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "Request Success Count". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "Request Duration". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "Retry Count". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "Request Success Count". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "Request Failure Count". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "Exception Count". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "Retry Count". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "Throttle Count". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "Throttle Count". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "Retry Count". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "Request Duration". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "Request Success Count". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "Exception Count". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "Exception Count". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "Request Duration". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "\Process(??APP_WIN32_PROC??)\% Processor Time". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "Request Success Count". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "Request Failure Count". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:@azure/opentelemetry-instrumentation-azure-sdk [
ApplicationInsights:Invalid metric name: "Request Failure Count". The metric name should be a ASCII string with a length no greater than 255 characters. []
ApplicationInsights:Invalid metric name: "Retry Count". The metric name should be a ASCII string with a length no greater than 255 characters. []
hectorhdzg commented 9 months ago

We are aware of this warnings, but these should not cause any change of behavior in the SDK, we fixed that in Azure Monitor OpenTelemetry Exporter recently and should be published soon.

Related to https://github.com/Azure/azure-sdk-for-js/pull/27179

Other issue related to Azure Instrumentation is also not causing problems but we are working on trying to avoid the unnecessary noise. Related to https://github.com/microsoft/ApplicationInsights-node.js/issues/1107

pedro37 commented 9 months ago

Thanks, I have another issue I have set a startActiveSpan but it is not showing in the appinsights metrics.

hectorhdzg commented 9 months ago

@pedro37 can you elaborate on your issue? what kind of metrics are you expecting to see?

pedro37 commented 9 months ago

Yes, I have essentially the following code snippet and I am expecting span-name to appear in the application insights metric dropdown, using the config above


startActiveSpan('span-name', (span) => {
  doSomething();
  span.end();
});
ericis commented 6 months ago

We are aware of this warnings, but these should not cause any change of behavior in the SDK, we fixed that in Azure Monitor OpenTelemetry Exporter recently and should be published soon.

Related to Azure/azure-sdk-for-js#27179

Other issue related to Azure Instrumentation is also not causing problems but we are working on trying to avoid the unnecessary noise. Related to #1107

These are not simply warnings. These output to the terminal when run, so it is not currently possible to use the Azure Monitor OpenTelemetry solution in a CLI, since every execution displays this (incredibly odd) "warning" to the users and the CLI developers do not have the ability to control this behavior: https://github.com/microsoft/ApplicationInsights-node.js/issues/1107#issuecomment-1876088622

sebastianvitterso commented 2 months ago

@hectorhdzg any update on this? We use applicationinsights for the main-thread of our electron app, but it still outputs eight lines whenever it's started (even in production):

Invalid metric name: "\ASP.NET Applications(??APP_W3SVC_PROC??)\Request Execution Time". The metric name should be a ASCII string with a length no greater than 255 characters. []
Invalid metric name: "\ASP.NET Applications(??APP_W3SVC_PROC??)\Requests/Sec". The metric name should be a ASCII string with a length no greater than 255 characters. []
Invalid metric name: "\Process(??APP_WIN32_PROC??)\Private Bytes". The metric name should be a ASCII string with a length no greater than 255 characters. []
Invalid metric name: "\Memory\Available Bytes". The metric name should be a ASCII string with a length no greater than 255 characters. []
Invalid metric name: "\Processor(_Total)\% Processor Time". The metric name should be a ASCII string with a length no greater than 255 characters. []
Invalid metric name: "\Process(??APP_WIN32_PROC??)\% Processor Time". The metric name should be a ASCII string with a length no greater than 255 characters. []
Accessing resource attributes before async attributes settled []
Accessing resource attributes before async attributes settled []
yarn.lock entry ``` applicationinsights@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/applicationinsights/-/applicationinsights-3.0.1.tgz#3967c804afa5ef590a7f014f9c630cb380f04454" integrity sha512-SbvRSveOduzYl1OFfW6zTnK/T8EFG6IqSlZ28orf/YTkLFvFZ9tgIffeY21xSzypYWKITkICyQpi+IiTQEgz0g== dependencies: "@azure/core-auth" "^1.3.0" "@azure/core-client" "^1.0.0" "@azure/core-rest-pipeline" "^1.9.2" "@azure/identity" "^3.1.3" "@azure/monitor-opentelemetry" "^1.4.0" "@azure/monitor-opentelemetry-exporter" "^1.0.0-beta.22" "@azure/opentelemetry-instrumentation-azure-sdk" "^1.0.0-beta.5" "@opentelemetry/api" "^1.8.0" "@opentelemetry/api-logs" "^0.50.0" "@opentelemetry/core" "^1.23.0" "@opentelemetry/exporter-logs-otlp-http" "^0.50.0" "@opentelemetry/exporter-metrics-otlp-http" "^0.50.0" "@opentelemetry/exporter-trace-otlp-http" "^0.50.0" "@opentelemetry/otlp-exporter-base" "^0.50.0" "@opentelemetry/resources" "^1.23.0" "@opentelemetry/sdk-logs" "^0.50.0" "@opentelemetry/sdk-metrics" "^1.23.0" "@opentelemetry/sdk-trace-base" "^1.23.0" "@opentelemetry/sdk-trace-node" "^1.23.0" "@opentelemetry/semantic-conventions" "^1.23.0" diagnostic-channel "1.1.1" diagnostic-channel-publishers "1.0.8" ```
skhilliard commented 2 months ago

I am also getting similar errors on startup....I am following the "upgrade" path...for example....

@azure/opentelemetry-instrumentation-azure-sdk [
  'Module @azure/core-tracing has been loaded before @azure/opentelemetry-instrumentation-azure-sdk so it might not work, please initialize it before requiring @azure/core-tracing'
]
Invalid metric name: "\ASP.NET Applications(??APP_W3SVC_PROC??)\Request Execution Time". The metric name should be a ASCII string with a length no greater than 255 characters. []
Invalid metric name: "\ASP.NET Applications(??APP_W3SVC_PROC??)\Requests/Sec". The metric name should be a ASCII string with a length no greater than 255 characters. []
Invalid metric name: "\Process(??APP_WIN32_PROC??)\Private Bytes". The metric name should be a ASCII string with a length no greater than 255 characters. []
Invalid metric name: "\Memory\Available Bytes". The metric name should be a ASCII string with a length no greater than 255 characters. []
Invalid metric name: "\Processor(_Total)\% Processor Time". The metric name should be a ASCII string with a length no greater than 255 characters. []
Invalid metric name: "\Process(??APP_WIN32_PROC??)\% Processor Time". The metric name should be a ASCII string with a length no greater than 255 characters. []
Accessing resource attributes before async attributes settled []
The iKey configuration option is not supported by the shim. Please configure the the connection string instead. Please reference the Azure Monitor OpenTelemetry Migration Doc for more information. If this functionality is required, please revert to Application Insights 2.X SDK. []

...additionally, I am not sure why I am getting this error...

The iKey configuration option is not supported by the shim. Please configure the the connection string instead. Please reference the Azure Monitor OpenTelemetry Migration Doc for more information. If this functionality is required, please revert to Application Insights 2.X SDK. []

I am initializing it this way...

import * as appinsights from 'applicationinsights';
if (!!process.env.APPINSIGHTS_INSTRUMENTATIONKEY) {
    appinsights
        .setup(process.env.APPINSIGHTS_INSTRUMENTATIONKEY)
        .setDistributedTracingMode(appinsights.DistributedTracingModes.AI_AND_W3C)
        .start();
    appinsights.defaultClient.config.enableLoggerErrorToTrace = true;
}

The value of process.env.APPINSIGHTS_INSTRUMENTATIONKEY is actually of the form InstrumentationKey=xxxxx

Also one other question (I can create a separate item for this if needed)....am I still allowed to track custom metrics and events thusly?

appinsights.defaultClient.trackMetric({ name: 'Redis Health Check', value: 1 });

appinsights.defaultClient.trackEvent({
    name: UserChallengeEvent.loginAttemptAccountLocked,
    properties: {
        userId: user._id
    }
});
JacksonWeber commented 1 month ago

@pedro37 @sebastianvitterso The invalid metric name warnings are resolved as of 3.1.0. The last two warnings (regarding the @azure/core-tracing package and Accessing resource attributes before async attributes settled) we are aware of and working to resolve. I can update this thread once they are.

antoinemuchbetter commented 2 weeks ago

I am using version 3.1.0 and still have warnings.