Open lnmp4000 opened 1 month ago
Hi @lnmp4000, thanks for reaching out. I was under the impression that this would actually get tree-shaken out for users of the @opentelemetry/exporter-trace-otlp-http
package - but I'm not very familar with rollup
so I'd be somewhat time consuming to come up with a repro for this. Maybe it's generating that warning before it's tree-shaken out?
Would you mind providing a small repro so I can investigate? :thinking:
Is it an error or a warning that's generated by rollup
?
Regardless of tree-shaking, we still use this in @opentelemetry/exporter-trace-otlp-proto
and @opentelemetry/exporter-logs-otlp-proto
and looking at the the issue you linked, my preferred solution would be to fix this upstream in the protobufjs
repo as this seems to affect quite a few people...
Would you mind providing a small repro so I can investigate? 🤔
Nevermind, I took some time to reproduce this :slightly_smiling_face: https://github.com/pichlermarc/repro-4987
Is it an error or a warning that's generated by rollup?
Looking at my reproducer it looks like the following is happening:
eval
does not end up in the final bundleTherefore code using @opentelemetry/exporter-trace-otlp-http
does not violate CSPs by using eval, but using @opentelemetry/exporter-trace-otlp-proto
does, as the eval
call will eventually end up in the final bundle.
There's a few ways we can partially/fully fix this:
@opentelemetry/otlp-transformer
can have multiple entrypoints, one for json
and one for protobuf
serialization
@opentelemetry/exporter-trace-otlp-http
@opentelemetry/exporter-trace-otlp-proto
protobuf
serialization from scratch, not using generated code, and not using @protobufjs/inquire
@opentelemetry/exporter-trace-otlp-http
and the violation of CSPs by @opentelemetry/exporter-trace-otlp-proto
@protobufjs/inquire
@opentelemetry/exporter-trace-otlp-http
and the violation of CSPs by @opentelemetry/exporter-trace-otlp-proto
@protobufjs/inquire
either directly or transitively.protobufjs
@pichlermarc Thanks so much for looking at this. In my case, based on your research, It seems I can just ignore this warning for now as the eval
code will not be in the final bundle.
@pichlermarc Thanks so much for looking at this. In my case, based on your research, It seems I can just ignore this warning for now as the
eval
code will not be in the final bundle.
Yes, exactly. :slightly_smiling_face:
If you don't mind, I'll spin off two bugs from this issue to clarify the situation:
eval()
-use warning for OTLP JSON exporters when using rollup
(priority:p4
, reason: logspam, misleading log)eval()
(priority:p1
reason: causes problems in end-user apps)
Bundling with rollupjs generated the following error because of
protobufjs
usage.This is included via the following tree:
I don't understand why this is necessary, but it could potentially cause issues for code bundled via rollup.
https://rollupjs.org/troubleshooting/#avoiding-eval
Also see https://github.com/protobufjs/protobuf.js/issues/1754