opentelemetry-js icon indicating copy to clipboard operation
opentelemetry-js copied to clipboard

Microfrontend+BFF integration with opentelemetry

Open AM1988 opened this issue 3 years ago • 1 comments
trafficstars

Discussed in https://github.com/open-telemetry/opentelemetry-js/discussions/3418

Originally posted by AM1988 November 17, 2022 Hi there.

I have an Angular micro frontend application that communicates with express BFF(backend for frontend).

It is bundled with webpack during the build step and lives in a docker container.

The frontend part uses @jufab/opentelemetry-angular-interceptor and BFF - using require like node -r "./tracer.js" index.js.

When I am starting the container I see weird logs like:

@opentelemetry/api: Registered a global for diag v1.2.0.
@opentelemetry/api: Registered a global for trace v1.2.0.
@opentelemetry/api: Registered a global for context v1.2.0.
@opentelemetry/api: Registered a global for propagation v1.2.0.
@opentelemetry/instrumentation-http Applying patch for [email protected]
@opentelemetry/instrumentation-http Applying patch for [email protected]
{"level":"INFO","message":"Express server is listening on http://localhost:5000","traceId":"not_available","timestamp":"2022-11-17T12:00:52.484Z"}
e found resource. e { attributes: {} }
e found resource. e {
  attributes: {
    'process.pid': 23,
    'process.executable.name': 'node',
    'process.command': '/app/index.js',
    'process.command_line': '/usr/bin/node /app/index.js',
    'process.runtime.version': '16.17.1',
    'process.runtime.name': 'nodejs',
    'process.runtime.description': 'Node.js'
  }
}
Error: @opentelemetry/api: Attempted duplicate registration of API: trace
    at l (/app/tracer.js:1:4498)
    at e.setGlobalTracerProvider (/app/tracer.js:1:15189)
    at u.e.register (/app/tracer.js:1:463626)
    at u.register (/app/tracer.js:1:408917)
    at t.NodeSDK.start (/app/tracer.js:1:312285)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async /app/tracer.js:1:547380
Error: @opentelemetry/api: Attempted duplicate registration of API: context
    at l (/app/tracer.js:1:4498)
    at e.setGlobalContextManager (/app/tracer.js:1:9869)
    at u.e.register (/app/tracer.js:1:463753)
    at u.register (/app/tracer.js:1:408917)
    at t.NodeSDK.start (/app/tracer.js:1:312285)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async /app/tracer.js:1:547380
Error: @opentelemetry/api: Attempted duplicate registration of API: propagation

and when the trace is being sent

    links: [],
    events: [],
    status: { code: 0 },
    endTime: [ 1668686488, 733854133 ],
    _ended: true,
    _duration: [ 0, 3654625 ],
    name: 'HTTP GET',
    _spanContext: {
      traceId: '1a1f7248060eba1701bd703b0cd2f816',
      spanId: '29e3976b17c39a63',
      traceFlags: 1,
      traceState: undefined
    },
    parentSpanId: undefined,
    kind: 1,
    startTime: [ 1668686488, 730199508 ],
    resource: e { attributes: [Object] },
    instrumentationLibrary: {
      name: '@opentelemetry/instrumentation-http',
      version: '0.32.0',
      schemaUrl: undefined
    },
    _spanLimits: {
      attributeValueLengthLimit: Infinity,
      attributeCountLimit: 128,
      linkCountLimit: 128,
      eventCountLimit: 128
    },
    _spanProcessor: e { _spanProcessors: [Array] },
    _attributeValueLengthLimit: Infinity
  }
]
Instrumentation suppressed, returning Noop Span

As a result I do not see any result is eager. What could be the reason for that?

AM1988 avatar Nov 18 '22 08:11 AM1988

Discussed in #3418

Originally posted by AM1988 November 17, 2022 Hi there.

I have an Angular micro frontend application that communicates with express BFF(backend for frontend).

It is bundled with webpack during the build step and lives in a docker container.

The frontend part uses @jufab/opentelemetry-angular-interceptor and BFF - using require like node -r "./tracer.js" index.js.

When I am starting the container I see weird logs like:

@opentelemetry/api: Registered a global for diag v1.2.0.
@opentelemetry/api: Registered a global for trace v1.2.0.
@opentelemetry/api: Registered a global for context v1.2.0.
@opentelemetry/api: Registered a global for propagation v1.2.0.
@opentelemetry/instrumentation-http Applying patch for [email protected]
@opentelemetry/instrumentation-http Applying patch for [email protected]
{"level":"INFO","message":"Express server is listening on http://localhost:5000","traceId":"not_available","timestamp":"2022-11-17T12:00:52.484Z"}
e found resource. e { attributes: {} }
e found resource. e {
  attributes: {
    'process.pid': 23,
    'process.executable.name': 'node',
    'process.command': '/app/index.js',
    'process.command_line': '/usr/bin/node /app/index.js',
    'process.runtime.version': '16.17.1',
    'process.runtime.name': 'nodejs',
    'process.runtime.description': 'Node.js'
  }
}
Error: @opentelemetry/api: Attempted duplicate registration of API: trace
    at l (/app/tracer.js:1:4498)
    at e.setGlobalTracerProvider (/app/tracer.js:1:15189)
    at u.e.register (/app/tracer.js:1:463626)
    at u.register (/app/tracer.js:1:408917)
    at t.NodeSDK.start (/app/tracer.js:1:312285)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async /app/tracer.js:1:547380
Error: @opentelemetry/api: Attempted duplicate registration of API: context
    at l (/app/tracer.js:1:4498)
    at e.setGlobalContextManager (/app/tracer.js:1:9869)
    at u.e.register (/app/tracer.js:1:463753)
    at u.register (/app/tracer.js:1:408917)
    at t.NodeSDK.start (/app/tracer.js:1:312285)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async /app/tracer.js:1:547380
Error: @opentelemetry/api: Attempted duplicate registration of API: propagation

and when the trace is being sent

    links: [],
    events: [],
    status: { code: 0 },
    endTime: [ 1668686488, 733854133 ],
    _ended: true,
    _duration: [ 0, 3654625 ],
    name: 'HTTP GET',
    _spanContext: {
      traceId: '1a1f7248060eba1701bd703b0cd2f816',
      spanId: '29e3976b17c39a63',
      traceFlags: 1,
      traceState: undefined
    },
    parentSpanId: undefined,
    kind: 1,
    startTime: [ 1668686488, 730199508 ],
    resource: e { attributes: [Object] },
    instrumentationLibrary: {
      name: '@opentelemetry/instrumentation-http',
      version: '0.32.0',
      schemaUrl: undefined
    },
    _spanLimits: {
      attributeValueLengthLimit: Infinity,
      attributeCountLimit: 128,
      linkCountLimit: 128,
      eventCountLimit: 128
    },
    _spanProcessor: e { _spanProcessors: [Array] },
    _attributeValueLengthLimit: Infinity
  }
]
Instrumentation suppressed, returning Noop Span

As a result I do not see any result is eager. What could be the reason for that?

We also use the micro front-end framework called qiankun. If the provider is initialized in the sub application and the route is switched, the page will be stuck and will not render. It seems that the memory has overflowed

yuanman0109 avatar Nov 20 '22 09:11 yuanman0109

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.

github-actions[bot] avatar Jan 23 '23 06:01 github-actions[bot]

This issue was closed because it has been stale for 14 days with no activity.

github-actions[bot] avatar Feb 06 '23 06:02 github-actions[bot]