opentelemetry-js
opentelemetry-js copied to clipboard
ApplicationInsights:Error: @opentelemetry/api: Attempted duplicate registration of API: propagation #1229
Facing issue when I'm using the Application Insights-Node package in the page.
import Container from 'components/core/container/Container';
import { GetServerSideProps } from 'next';
const Page = () => {
return (
<Container>
<div className="page-wrapper">P+ Landing Page - Under construction</div>
</Container>
);
};
export const getServerSideProps: GetServerSideProps<any> = async () => {
if (process.env.NEXT_RUNTIME === 'nodejs') {
let appInsights = require("applicationinsights");
appInsights.setup("connectionstring from azure").start();
let client = appInsights.defaultClient;
client.trackEvent({name: "my custom event", properties: {customProperty: "custom property value"}});
}
try {
await fetch('exception');
} catch (e: any) {
// appInsights.defaultClient.trackException({ exception: e });
}
return { props: { success: false } };
};
export default Page;
Also I'm not seeing any logs in the azure app insights.
Error:
clinical-content:dev: ApplicationInsights:Error: @opentelemetry/api: Attempted duplicate registration of API: propagation clinical-content:dev: at registerGlobal (/home/newApp/PatientNextGen/node_modules/.pnpm/@[email protected]/node_modules/@opentelemetry/api/build/src/internal/global-utils.js:32:21) clinical-content:dev: at PropagationAPI.setGlobalPropagator (/home/newApp/PatientNextGen/node_modules/.pnpm/@[email protected]/node_modules/@opentelemetry/api/build/src/api/propagation.js:52:50) clinical-content:dev: at NodeTracerProvider.register (/home/newApp/PatientNextGen/node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@opentelemetry/sdk-trace-base/build/src/BasicTracerProvider.js:100:31) clinical-content:dev: at NodeTracerProvider.register (/home/newApp/PatientNextGen/node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@opentelemetry/sdk-trace-node/build/src/NodeTracerProvider.js:43:15) clinical-content:dev: at new TraceHandler (/home/newApp/PatientNextGen/node_modules/.pnpm/@[email protected]/node_modules/@azure/monitor-opentelemetry/dist/index.js:955:30) clinical-content:dev: at useAzureMonitor (/home/newApp/PatientNextGen/node_modules/.pnpm/@[email protected]/node_modules/@azure/monitor-opentelemetry/dist/index.js:1136:20) clinical-content:dev: at useAzureMonitor (/home/newApp/PatientNextGen/node_modules/.pnpm/[email protected]/node_modules/applicationinsights/out/src/main.js:30:49) clinical-content:dev: at TelemetryClient.initialize (/home/newApp/PatientNextGen/node_modules/.pnpm/[email protected]/node_modules/applicationinsights/out/src/shim/telemetryClient.js:37:36) clinical-content:dev: at Configuration.start (/home/newApp/PatientNextGen/node_modules/.pnpm/[email protected]/node_modules/applicationinsights/out/src/shim/applicationinsights.js:36:31) clinical-content:dev: at getServerSideProps (webpack-internal:///./pages/doctor/index.tsx:30:220) clinical-content:dev: at /home/newApp/PatientNextGen/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/dist/server/render.js:551:26 clinical-content:dev: at /home/newApp/PatientNextGen/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/dist/server/lib/trace/tracer.js:117:36 clinical-content:dev: at AsyncLocalStorage.run (node:async_hooks:346:14) clinical-content:dev: at AsyncLocalStorageContextManager.with (/home/newApp/PatientNextGen/node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@opentelemetry/context-async-hooks/build/src/AsyncLocalStorageContextManager.js:33:40) clinical-content:dev: at ContextAPI.with (/home/newApp/PatientNextGen/node_modules/.pnpm/@[email protected]/node_modules/@opentelemetry/api/build/src/api/context.js:60:46) clinical-content:dev: at Tracer.startActiveSpan (/home/newApp/PatientNextGen/node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@opentelemetry/sdk-trace-base/build/src/Tracer.js:122:32) clinical-content:dev: at /home/newApp/PatientNextGen/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/dist/server/lib/trace/tracer.js:106:107 clinical-content:dev: at AsyncLocalStorage.run (node:async_hooks:346:14) clinical-content:dev: at AsyncLocalStorageContextManager.with (/home/newApp/PatientNextGen/node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@opentelemetry/context-async-hooks/build/src/AsyncLocalStorageContextManager.js:33:40) clinical-content:dev: at ContextAPI.with (/home/newApp/PatientNextGen/node_modules/.pnpm/@[email protected]/node_modules/@opentelemetry/api/build/src/api/context.js:60:46) clinical-content:dev: at NextTracerImpl.trace (/home/newApp/PatientNextGen/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/dist/server/lib/trace/tracer.js:106:32) clinical-content:dev: at renderToHTMLImpl (/home/newApp/PatientNextGen/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/dist/server/render.js:546:51) clinical-content:dev: at process.processTicksAndRejections (node:internal/process/task_queues:95:5) clinical-content:dev: at async doRender (/home/newApp/PatientNextGen/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/dist/server/base-server.js:1140:26) clinical-content:dev: at async cacheEntry.responseCache.get.incrementalCache.incrementalCache (/home/newApp/PatientNextGen/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/dist/server/base-server.js:1300:28) clinical-content:dev: at async /home/newApp/PatientNextGen/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/dist/server/response-cache/index.js:99:36 [] clinical-content:dev: ApplicationInsights:@azure/opentelemetry-instrumentation-azure-sdk [ clinical-content:dev: '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' clinical-content:dev: ] clinical-content:dev: ApplicationInsights:Invalid metric name: "\ASP.NET Applications(??APP_W3SVC_PROC??)\Request Execution Time". The metric name should be a ASCII string with a length no greater than 255 characters. [] clinical-content:dev: ApplicationInsights:Invalid metric name: "\ASP.NET Applications(??APP_W3SVC_PROC??)\Requests/Sec". The metric name should be a ASCII string with a length no greater than 255 characters. [] clinical-content:dev: ApplicationInsights:Invalid metric name: "\Process(??APP_WIN32_PROC??)\Private Bytes". The metric name should be a ASCII string with a length no greater than 255 characters. [] clinical-content:dev: ApplicationInsights:Invalid metric name: "\Memory\Available Bytes". The metric name should be a ASCII string with a length no greater than 255 characters. [] clinical-content:dev: ApplicationInsights:Invalid metric name: "\Processor(_Total)% Processor Time". The metric name should be a ASCII string with a length no greater than 255 characters. [] clinical-content:dev: ApplicationInsights:Invalid metric name: "\Process(??APP_WIN32_PROC??)% Processor Time". The metric name should be a ASCII string with a length no greater than 255 characters.
Hi I'm facing the same issue with my development build.
seems this is caused by either the application installs two OTel instances (one via applicationinsights => @azure/monitor-opentelemetry) or applicationinsights does something wrong.
I guess it's better to ask the azure team here.
/cc @MSNev
@hectorhdzg , @JacksonWeber can you please look at this
@Ramemis which version of Application Insights are you using? this error is usually triggered when multiple global registrations occur in OpenTelemetry, that could be caused by having multiple telemetry clients being created, that would not be supported anymore very soon in applicationinsights beta package, I recommend you take a look at Azure Monitor OpenTelemetry Distro to have your data in Application Insights
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.
This issue was closed because it has been stale for 14 days with no activity.