microsoft / ApplicationInsights-node.js

Microsoft Application Insights SDK for Node.js
MIT License
325 stars 139 forks source link

Problem with setAutoCollectRequests(). Requests are not being sent to application insights #1349

Open nandeeswar-elanco opened 5 months ago

nandeeswar-elanco commented 5 months ago

Requests are not being automatically logged in application insights, only custom telemetry is being logged applicationinsights version 3.1.0

I see a few warnings in the terminal on application start

@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' ] @opentelemetry/instrumentation-winston [ 'Module winston has been loaded before @opentelemetry/instrumentation-winston so it might not work, please initialize it before requiring winston' ] @opentelemetry/instrumentation-winston [ 'Module winston has been loaded before @opentelemetry/instrumentation-winston so it might not work, please initialize it before requiring winston' ] Accessing resource attributes before async attributes settled []

I am not sure if these warnings are an issue

code setup: app.ts

import express = require('express'); import { useExpressServer } from 'routing-controllers'; import { HealthCheckMiddleware } from './middlewares/health-check-middleware'; import { appInsightsLoader } from './applicationInsights/app-insights-loader'; import { UserController } from './controllers/user-controller';

/**

/**

export { app };

app-insights-loader.ts

import appInsights = require('applicationinsights'); import { env } from '../env';

const appInsightsLoader = (): void => { if (env.APPLICATIONINSIGHTS_ENABLED) { appInsights .setup(env.APPLICATIONINSIGHTS_CONNECTION_STRING) .setAutoCollectRequests(true) .setAutoCollectExceptions(true) .setAutoCollectDependencies(false) .setAutoCollectConsole(true) .setSendLiveMetrics(false) .start(); } };

export { appInsightsLoader };

JacksonWeber commented 5 months ago

@nandeeswar-elanco The winston-instrumentation warnings are not expected. Please make sure to initialize the Application Insights SDK before importing the winston module.

Regarding requests specifically, do you have an example of a code snippet you're expecting to generate request telemetry?