-
Notifications
You must be signed in to change notification settings - Fork 140
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
Unable to integrate with Winston logger #1320
Comments
@JPStrydom I was able to fix your example by modifying your 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! |
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. |
@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. |
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
|
@JPStrydom For removing the extended metrics warning, simply change 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 |
@JPStrydom Please let me know if this has been able to resolve your issue, thanks! |
We've temporarily paused development on the AppInsights integration, but as soon as we resume, I'll test and let you know. Thanks! |
Issue
We're unable to get
applicationinsights
to communicate with our AppInsights instance viawinston
.Versions
Steps to reporduce
I've attached a minimum reproduceable example here:
applicationinsights-winston-issue.zip
In the example, we currently have the following
package.json
file:And the following
index.js
file:npm i
npm t
What else we've tried
We've also tried manually sending the logs to AppInsights with:
When running like this, then we get the following logs:
This appears to work, but then we get an additional
info
log (bottom of the above example image) and a few of theAccessing resource attributes before async attributes settled []
error logs (top and 2nd from the bottom of the above example image) as well.This solution also requires us to install the
stream
package, which is not ideal.How to fix?
We are receiving logs from our other applications, so AppInsights appears to be working, but we're unable to communicate via Winston from on NodeJS app.
How can we go about integrating with Winston?
The text was updated successfully, but these errors were encountered: