-
Notifications
You must be signed in to change notification settings - Fork 821
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
Grpc OpenTelemetry Collector Exporter not showing traces with webpack #2786
Comments
the exporter loads the proto files async when it is initialized. Most likely the proto files are not included in the webpack bundle. Your module rules only seem to pick up .ts, .js, and .node files. The proto files are .proto. |
@dyladan Would you be able to give an example on this? |
Unfortunately I'm not a webpack expert and I don't know immediately how to do this. I would search how to bundle proto files in webpack or possibly use something like file-loader to bundle any non-js files. |
I also ran into this issue when using esbuild to bundle my application for AWS Lambda. The problem for me was this line
in conjunction with these lines opentelemetry-js/experimental/packages/exporter-trace-otlp-grpc/src/OTLPTraceExporter.ts Lines 69 to 71 in 5d9ed3f
I took care to copy the opentelemetry/proto/collector/trace/v1/ directory into the app directory which would ultimately execute inside of my Lambda. Then, I bundled my code. The result is
However,
Ultimately it worked… but could it be easier? I don't know how the |
It is possible to precompile .proto files into their json representations or to static JS but there are other considerations such as bundle size and performance impact there. The proto files are loaded by protobufjs to define the serialization format. |
We've just hit this problem using opentelemetry with esbuild, it would be really helpful if the |
We've run into this problem while using any transpiler or bundler which includes Webpack, ESBuild and TypeScript. A workaround I found that works is configuring your bundler to copy the proto files out of For the package to find the proto files in the right spot, the output build directory and the ESBuild Config:
Webpack config:
TypeScript config currently does not have a way to specify copying extra files you may need for your build, so in this case you would have to use a It would be really helpful to see a solution that doesn't require special build config for bundlers, especially since Node + TypeScript is a very common stack. |
One possibility we considered is instead of using .proto files we could check in code generated based on them but nobody has had the time to work on that. @pichlermarc was doing a lot of work factoring out the transformation code that might make that quite a bit easier of a project now if anyone is interested in taking it on. |
I think this is not a bug because it is known the gRPC doesn't work in webpacked environments because of these proto files. There are workarounds like using a webpack plugin to copy the proto files. I'm changing this to a feature request as I view the request "please make the exporter work out of the box with webpack without configuration" |
I disagree that this is not a bug. Bundling is fairly common, and expecting libraries to support bundling is not entirely unreasonable. The request is not that it work out of the box with webpack without configuration, but that it work with bundlers in general with a clearly documented workaround. Such a workaround could be that
path.resolve(__dirname, 'protos') and the documentation said that to work with a bundler, these files must be present- and give a location to get them from.
The workaround we have used is to mark this entire module as external in esbuild and include a node_modules directory with this package in alongside our bundle. |
We can discuss this in SIG today |
@dyladan thanks for discussing this, what was the outcome of the discussion? |
We agreed this is not a bug. I'm currently reworking the exporters to use generated code instead of loading .proto files so that should fix the webpack issue. |
thanks 👍 |
@dyladan any news on this? |
Not really. The protobuf http exporters now have generated code so they shouldn't have this issue but the gRPC exporters have not gotten the same treatment. |
👋 Is there any updates on this issue? |
Please answer these questions before submitting a bug report.
What version of OpenTelemetry are you using?
What version of Node are you using?
v16.13.2
Please provide the code you used to setup the OpenTelemetry SDK
Converted the sample app to ts
What did you do?
Added a webpack file, with the following content, and tried running the tracing on the dist/index.js file.
What did you expect to see?
I expected to see the tracing from both the Otel Exporter and Console Exporter.
What did you see instead?
The Otel Exporter traces are not showing in localhost:4317, only the console exporter displays in console.
Additional context
This warning is always displayed -
opentelemetry/proto/collector/trace/v1/trace_service.proto not found in any of the include paths js-app\protos
I tried moving the protos folder into the path the warning displays... solves nothing still.
The traces display fine without webpack.
The text was updated successfully, but these errors were encountered: