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

[Instrumentation] Cannot build web project using webpack due to reference to nodejs core package (path) #4373

Closed
vpmedia opened this issue Dec 17, 2023 · 3 comments · Fixed by #4386
Assignees
Labels
bug Something isn't working pkg:instrumentation priority:p1 Bugs which cause problems in end-user applications such as crashes, data inconsistencies, etc

Comments

@vpmedia
Copy link

vpmedia commented Dec 17, 2023

What happened?

Steps to Reproduce

After upgrading to 0.46.0 try to build a web project using webpack.

Expected Result

Build success.

Actual Result

ERROR in ./node_modules/@opentelemetry/instrumentation/build/esm/instrumentationNodeModuleFile.js 16:0-33
Module not found: Error: Can't resolve 'path' in '/home/runner/work/PROJECT/node_modules/@opentelemetry/instrumentation/build/esm'

Additional Details

OpenTelemetry Setup Code

import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import { registerInstrumentations } from '@opentelemetry/instrumentation';
import { DocumentLoadInstrumentation } from '@opentelemetry/instrumentation-document-load';
import { FetchInstrumentation } from '@opentelemetry/instrumentation-fetch';
import { Resource } from '@opentelemetry/resources';
import { ConsoleMetricExporter, MeterProvider, PeriodicExportingMetricReader } from '@opentelemetry/sdk-metrics';
import {
  BatchSpanProcessor,
  ConsoleSpanExporter,
  SimpleSpanProcessor,
  TraceIdRatioBasedSampler,
  WebTracerProvider,
} from '@opentelemetry/sdk-trace-web';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';


...


registerInstrumentations({
    instrumentations: [documentLoadInstrumentation, fetchInstrumentation],
    tracerProvider: provider,
  });

package.json

"@opentelemetry/exporter-metrics-otlp-http": "^0.46.0",
"@opentelemetry/exporter-trace-otlp-http": "^0.46.0",
"@opentelemetry/instrumentation": "^0.46.0",
"@opentelemetry/instrumentation-document-load": "^0.34.0",
"@opentelemetry/instrumentation-fetch": "^0.46.0",
"@opentelemetry/instrumentation-user-interaction": "^0.34.0",
"@opentelemetry/instrumentation-xml-http-request": "^0.46.0",
"@opentelemetry/sdk-metrics": "^1.19.0",
"@opentelemetry/sdk-trace-web": "^1.19.0",

Relevant log output

ERROR in ./node_modules/@opentelemetry/instrumentation/build/esm/instrumentationNodeModuleFile.js 16:0-33
Module not found: Error: Can't resolve 'path' in '/home/runner/work/PROJECT/node_modules/@opentelemetry/instrumentation/build/esm'
@vpmedia vpmedia added bug Something isn't working triage labels Dec 17, 2023
@mattrodak
Copy link

I have the same issue on vite 4.5.1

"@opentelemetry/api": "^1.7.0",
"@opentelemetry/context-zone": "^1.19.0",
"@opentelemetry/exporter-zipkin": "^1.19.0",
"@opentelemetry/instrumentation-fetch": "^0.46.0",
"@opentelemetry/sdk-trace-web": "^1.19.0",

@pichlermarc pichlermarc added the priority:p1 Bugs which cause problems in end-user applications such as crashes, data inconsistencies, etc label Dec 18, 2023
@pichlermarc
Copy link
Member

Looks like some files ended up in the wrong place in a recent PR. I'm looking into it.

@vpmedia
Copy link
Author

vpmedia commented Dec 18, 2023

For WebPack users (as the compiler suggests) adding a resolve fallback to the 'path' package temporarily fixes the issue:

 resolve: {
    extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'],
    fallback: { 'path': false },
  },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pkg:instrumentation priority:p1 Bugs which cause problems in end-user applications such as crashes, data inconsistencies, etc
Projects
None yet
3 participants