microsoft / ApplicationInsights-node.js

Microsoft Application Insights SDK for Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

nandeeswar-elanco opened this issue · comments

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';

/**

  • Application Insights
    */
    appInsightsLoader();

/**

  • Application Setup
    */
    const expressInstance = express();
    const app = useExpressServer(expressInstance, {
    cors: true,
    middlewares: [HealthCheckMiddleware],
    controllers: [UserController],
    });

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 };

@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?