Comments (5)
@JPStrydom I was able to fix your example by modifying your index.js
to be the following:
let appInsights = require('applicationinsights');
appInsights.setup("your-instrumentation-key")
.setAutoCollectRequests(true)
.setAutoCollectPerformance(true, true)
.setAutoCollectExceptions(true)
.setAutoCollectDependencies(true)
.setAutoCollectConsole(true, true)
.setAutoCollectPreAggregatedMetrics(true)
.setSendLiveMetrics(false)
.setInternalLogging(false, true)
.enableWebInstrumentation(false)
.start()
const { createLogger, transports } = require('winston');
const logger = createLogger({
transports: [new transports.Console()]
})
async function test () {
logger.info('Info Test');
logger.warn('Warn Test');
logger.error('Error Test');
await appInsights.defaultClient.flush();
}
test();
The modification just ensures that the application waits to exit until the Application Insights SDK has gotten a chance to export the Winston logs. Please let me know if this example makes sense or if you have any other questions. Thanks!
from applicationinsights-node.js.
Hi @JacksonWeber !
Thanks for taking the time to reach out.
I tried your example and I managed to get a few logs, but still received many of the error logs:
Was your thinking that the client needs to be flushed after every log? I'm just scared that this makes our logging asynchronous, which we've not currently catered for.
from applicationinsights-node.js.
@JPStrydom It's great you were able to see the Winston logs! Those other logs you're seeing are warnings and they come from a few sources. The "accessing resource attributes" warning is from OpenTelemetry and reports this warning because we have a VM resource detector that makes an API call to a VM metadata service. Given that you're not running in that environment, the call times out, but using the SDK before that timeout generates this warning for now. It won't impact functionality for you.
The warning regarding extended metrics is because you're attempting to set a configuration option that used to modify the behavior of collection of extended metrics. However, like the warning mentions, we don't support extended metrics in versions greater than or equal to 3.0.0.
from applicationinsights-node.js.
Thanks again!
Given the setup config we have:
.setAutoCollectRequests(true)
.setAutoCollectPerformance(true, true)
.setAutoCollectExceptions(true)
.setAutoCollectDependencies(true)
.setAutoCollectConsole(true, true)
.setAutoCollectPreAggregatedMetrics(true)
.setSendLiveMetrics(false)
.setInternalLogging(false, true)
.enableWebInstrumentation(false)
Is there anything we need to change to get rid of the errors/warnings you mentioned?
I'd also just like some clarification on when exactly we need to call the appInsights.defaultClient.flush()
function:
- Do we need to call this after every log, OR
- Do we only need to call this once, OR
- Do we need to call it on an interval?
from applicationinsights-node.js.
@JPStrydom For removing the extended metrics warning, simply change .setAutoCollectPerformance(true, true)
to .setAutoCollectPerformance(true)
. You'll still auto collect performance counters, but the second parameter is for setting auto collection of extended metrics (which isn't supported).
As for the resource attributes warning, this isn't currently ignorable because we turn on resource detection by default for popular Azure Resources.
Regarding on when to use flush()
. It entirely depends on your application. If Node.js process flow ends quickly after a call to log telemetry, then it may make sense to await a flush()
however, in most cases, such as a long running Node.js server application there typically isn't any need to asynchronously await a flush.
from applicationinsights-node.js.
Related Issues (20)
- 3.0.0-beta.11 - has no exported member 'Context' HOT 19
- App insights customDimension parsing differently locally vs in Azure. HOT 1
- [Beta] - Nested objects get serialised as "[object Object]" again HOT 11
- [FEATURE] At startup, send all locally stored traces instead of waiting the first batch + some time HOT 8
- Error "body.data.baseData.ver cannot be null or undefined." HOT 12
- Importing Application Insights library in ES6 module import format doesn't work HOT 3
- Invalid metric name: The metric name should be a ASCII string with a length no greater than 255 characters. HOT 2
- @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' ] HOT 2
- trackTrace no longer working since this week HOT 1
- TrackEvent no longer reporting Measurements HOT 3
- Bunyan logger problems HOT 7
- _APPRESOURCEPREVIEW_ appearing in metrics when upgrading from 2.x to 3.0.1 HOT 5
- customMetrics problems HOT 2
- Upgrade 2.x to 3.0.1 startup warnings HOT 3
- [BUG] Custom proxy with error "Expecting a valid host string in proxy settings, but found" HOT 2
- [BUG] Custom proxy with error "Expecting a valid host string in proxy settings, but found" HOT 1
- "applicationinsights 3.1.0" is not compatible with the "@azure/functions 4.5.0" HOT 1
- Correlation between Frontend and Backend.
- Severitylevel does not work
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from applicationinsights-node.js.