Skip to content
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

ApplicationInsights:Error: @opentelemetry/api: Attempted duplicate registration of API: propagation #1229

Open
Ramemis opened this issue Oct 16, 2023 · 3 comments

Comments

@Ramemis
Copy link

Ramemis commented Oct 16, 2023

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/@opentelemetry+api@1.6.0/node_modules/@opentelemetry/api/build/src/internal/global-utils.js:32:21)
clinical-content:dev: at PropagationAPI.setGlobalPropagator (/home/newApp/PatientNextGen/node_modules/.pnpm/@opentelemetry+api@1.6.0/node_modules/@opentelemetry/api/build/src/api/propagation.js:52:50)
clinical-content:dev: at NodeTracerProvider.register (/home/newApp/PatientNextGen/node_modules/.pnpm/@opentelemetry+sdk-trace-base@1.17.1_@opentelemetry+api@1.6.0/node_modules/@opentelemetry/sdk-trace-base/build/src/BasicTracerProvider.js:100:31)
clinical-content:dev: at NodeTracerProvider.register (/home/newApp/PatientNextGen/node_modules/.pnpm/@opentelemetry+sdk-trace-node@1.17.1_@opentelemetry+api@1.6.0/node_modules/@opentelemetry/sdk-trace-node/build/src/NodeTracerProvider.js:43:15)
clinical-content:dev: at new TraceHandler (/home/newApp/PatientNextGen/node_modules/.pnpm/@Azure+monitor-opentelemetry@1.1.0/node_modules/@azure/monitor-opentelemetry/dist/index.js:955:30)
clinical-content:dev: at useAzureMonitor (/home/newApp/PatientNextGen/node_modules/.pnpm/@Azure+monitor-opentelemetry@1.1.0/node_modules/@azure/monitor-opentelemetry/dist/index.js:1136:20)
clinical-content:dev: at useAzureMonitor (/home/newApp/PatientNextGen/node_modules/.pnpm/applicationinsights@3.0.0-beta.10/node_modules/applicationinsights/out/src/main.js:30:49)
clinical-content:dev: at TelemetryClient.initialize (/home/newApp/PatientNextGen/node_modules/.pnpm/applicationinsights@3.0.0-beta.10/node_modules/applicationinsights/out/src/shim/telemetryClient.js:37:36)
clinical-content:dev: at Configuration.start (/home/newApp/PatientNextGen/node_modules/.pnpm/applicationinsights@3.0.0-beta.10/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/next@13.4.19_@babel+core@7.22.9_@opentelemetry+api@1.6.0_react-dom@18.2.0_react@18.2.0_sass@1.66.1/node_modules/next/dist/server/render.js:551:26
clinical-content:dev: at /home/newApp/PatientNextGen/node_modules/.pnpm/next@13.4.19_@babel+core@7.22.9_@opentelemetry+api@1.6.0_react-dom@18.2.0_react@18.2.0_sass@1.66.1/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/@opentelemetry+context-async-hooks@1.17.1_@opentelemetry+api@1.6.0/node_modules/@opentelemetry/context-async-hooks/build/src/AsyncLocalStorageContextManager.js:33:40)
clinical-content:dev: at ContextAPI.with (/home/newApp/PatientNextGen/node_modules/.pnpm/@opentelemetry+api@1.6.0/node_modules/@opentelemetry/api/build/src/api/context.js:60:46)
clinical-content:dev: at Tracer.startActiveSpan (/home/newApp/PatientNextGen/node_modules/.pnpm/@opentelemetry+sdk-trace-base@1.17.1_@opentelemetry+api@1.6.0/node_modules/@opentelemetry/sdk-trace-base/build/src/Tracer.js:122:32)
clinical-content:dev: at /home/newApp/PatientNextGen/node_modules/.pnpm/next@13.4.19_@babel+core@7.22.9_@opentelemetry+api@1.6.0_react-dom@18.2.0_react@18.2.0_sass@1.66.1/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/@opentelemetry+context-async-hooks@1.17.1_@opentelemetry+api@1.6.0/node_modules/@opentelemetry/context-async-hooks/build/src/AsyncLocalStorageContextManager.js:33:40)
clinical-content:dev: at ContextAPI.with (/home/newApp/PatientNextGen/node_modules/.pnpm/@opentelemetry+api@1.6.0/node_modules/@opentelemetry/api/build/src/api/context.js:60:46)
clinical-content:dev: at NextTracerImpl.trace (/home/newApp/PatientNextGen/node_modules/.pnpm/next@13.4.19_@babel+core@7.22.9_@opentelemetry+api@1.6.0_react-dom@18.2.0_react@18.2.0_sass@1.66.1/node_modules/next/dist/server/lib/trace/tracer.js:106:32)
clinical-content:dev: at renderToHTMLImpl (/home/newApp/PatientNextGen/node_modules/.pnpm/next@13.4.19_@babel+core@7.22.9_@opentelemetry+api@1.6.0_react-dom@18.2.0_react@18.2.0_sass@1.66.1/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/next@13.4.19_@babel+core@7.22.9_@opentelemetry+api@1.6.0_react-dom@18.2.0_react@18.2.0_sass@1.66.1/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/next@13.4.19_@babel+core@7.22.9_@opentelemetry+api@1.6.0_react-dom@18.2.0_react@18.2.0_sass@1.66.1/node_modules/next/dist/server/base-server.js:1300:28)
clinical-content:dev: at async /home/newApp/PatientNextGen/node_modules/.pnpm/next@13.4.19_@babel+core@7.22.9_@opentelemetry+api@1.6.0_react-dom@18.2.0_react@18.2.0_sass@1.66.1/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.

@JacksonWeber
Copy link
Contributor

@Ramemis What version of the ApplicationInsights SDK are you using?

@lapa182
Copy link

lapa182 commented Nov 15, 2023

@JacksonWeber I have the same issue and I'm running 3.0.0-beta.10

@JacksonWeber
Copy link
Contributor

@lapa182 @Ramemis If you are using the Application Insights shim in the beta and the TelemetryClient, you'll get this error. What's happening is that OpenTelemetry is trying to register two global providers. In this case only the first provider will win. There's a paradigm shift in how handling what would have been handled by two TelemetryClients in the past should be handled now. With OpenTelemetry you should be able to create multiple span processors in order to achieve effectively the same as the multiple TelemetryClients.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants