-
Notifications
You must be signed in to change notification settings - Fork 138
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
[Beta] Error that @azure/core-tracing is loaded before @azure/opentelemetry-instrumentation-azure-sdk #1107
Comments
I got the same warning when trying out the beta package. |
Hello. I get the same error. Are there any updates on this? |
This is not an error just a warning, Azure SDK auto instrumentation should be functional even if the warning is triggered, please ignore for now, this warning would be gone once we add a LogExporter and remove internal @Azure package dependencies in this project |
@hectorhdzg this actually appears in my program's output. We are generating a Node CLI that uses command telemetry through the SDK. So, this so-called "warning" is not simply output to logs on a server, but actually written out to the console whenever any command is executed. How can we avoid this? |
@ericis this is an internal log, so you should be able to control it changing the log level, you can also change the log destination to be file and console would not be written. |
Thank you @hectorhdzg . It seems it is not possible to override the logging in the usual way. I was surprised that the "@azure/monitor-opentelemetry" package has it's own As a result, there are THREE logging overrides to be successful while using the "@azure/opentelemetry-instrumentation-azure-sdk" library. Override "@opentelemetry/api" loggingimport api, {
DiagLogger,
DiagLoggerOptions,
} from '@opentelemetry/api'
const openTelemetryLogger: DiagLogger = {
debug: (message: string, ...args: unknown[]) => {
// no-op example
},
error: (message: string, ...args: unknown[]) => {
// no-op example
},
info: (message: string, ...args: unknown[]) => {
// no-op example
},
verbose: (message: string, ...args: unknown[]) => {
// no-op example
},
warn: (message: string, ...args: unknown[]) => {
// no-op example
},
}
const openTelemetryLoggerOptions: DiagLoggerOptions = {
suppressOverrideMessage: true,
}
api.diag.setLogger(openTelemetryLogger, openTelemetryLoggerOptions) Override "@azure/logger" loggingimport { AzureLogger } from '@azure/logger'
AzureLogger.log = (...args: any[]) => {
// no-op example
} Override "@azure/opentelemetry-instrumentation-azure-sdk" loggingThis is not currently possible. Instead, all warnings have to be ignored in order to ignore this one message or logging has to be redirected to an output file in order to suppress it from the console. This is inconsistent with the OpenTelemetry logging and Azure SDK logging solutions and does not provide the developer with enough control. process.env.APPLICATIONINSIGHTS_INSTRUMENTATION_LOGGING_LEVEL = "INFO";
process.env.APPLICATIONINSIGHTS_LOG_DESTINATION = "file";
process.env.APPLICATIONINSIGHTS_LOGDIR = "C:/applicationinsights/logs"; |
Given the current limitations of the "@azure/opentelemetry-instrumentation-azure-sdk" logging, I was able to workaround this issue with a fairly significant flaw that logging details will be treated very differently for this specific library than anything else in the application. This also limits our future ability to redirect these log entries and mandates that the developers are all aware that there is a separate "appinsights" log file for the application. // map to AppInsights-specific log levels
const getAppInsightsLogLevel = (logLevel: LogLevel) => {
// NONE, ERROR, WARN, INFO, DEBUG, VERBOSE and ALL
// https://github.com/microsoft/ApplicationInsights-node.js/tree/beta?tab=readme-ov-file#self-diagnostics
switch (logLevel) {
case LogLevel.debug:
return 'DEBUG'
case LogLevel.error:
return 'ERROR'
case LogLevel.info:
return 'INFO'
case LogLevel.warn:
return 'WARN'
default:
return 'NONE'
}
}
// BUG: AppInsights and Azure OpenTelemetry do not offer the ability to
// override logging. As a result, the only option to prevent log
// details from "spilling" into the console is to send it to a file.
// Of course, this also results in important information like Errors
// being sent to a separate log file with no ability to control how
// they are reported.
const appInsightsLogFilePath = path.join(
options.config.dataDir,
'my-cli.appinsights.log'
)
process.env.APPLICATIONINSIGHTS_INSTRUMENTATION_LOGGING_LEVEL =
getAppInsightsLogLevel(activeLogLevel)
process.env.APPLICATIONINSIGHTS_LOG_DESTINATION = 'file'
process.env.APPLICATIONINSIGHTS_LOGDIR = appInsightsLogFilePath |
@ericis I'm a little bit confused about what is your specific need, we do in fact have multiple loggers involved, as we use both OpenTelemetry and Azure SDK packages in our SDK, I can see level works as expected when using application insights config, we do not support filtering out specific logs so there is no way to filter out the current warning without changing the level to error. Can you describe your scenario?, are you using other Azure SDKs and expecting to be able to override Azure SDK logger?, we are working on improving internal logging here, I can see we have some flaws but understanding your issue better could help us to include it as well. |
Thanks @hectorhdzg . Sorry for the confusion. If I were to take a step back, while I can't speak for all developers, I might hypothesize that developer joy when using OpenTelemetry + Azure would be to assume that overriding the However, I have some empathy toward the fact that |
Thanks @ericis for extra details, I created following PR related to that |
Hello,
I'm using the latest beta-version of this package, however, on startup, I'm getting the following error:
I don't have those packages as a dependency, and I don't import/require them anywhere, so I guess the error originates from this package. Is this a bug?
The text was updated successfully, but these errors were encountered: