-
Notifications
You must be signed in to change notification settings - Fork 836
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
OTLPTraceExporter from exporter-trace-otlp-http exporting traces Base64 encoded in React Native #5178
Comments
Hi @Dsalvat596, thanks for reporting this. Just to clarify: are you saying that this does work in a react web app, but does not work in react native? 🤔 |
Hi @pichlermarc, thanks for responding. Yes, it does work as expected in the react web app, no polyfill needed. I should mention this is an Expo app, and the documentation here indicates Im not sure if this issue is related or it is something specific to the exporter itself. |
Hmm, that's weird. Unfortunately I'm not really familiar with any of these tools and react-native itself - so it's difficult for me to figure out how to get started.. 😞 Would you be able to provide a simple repository that I can use to investigate this? 🤔 |
hey @Dsalvat596, the react native app on the demo repo isn't merged yet but can be helpful to try and reproduce, I reduced its tracer setup a bit to match your code snippet and wasn't able to see the problem here: open-telemetry/opentelemetry-demo@fe81089 but then downgrading to RN v0.73.6 I do see that exception about TextEncoder raised: open-telemetry/opentelemetry-demo@a6ca5da I'm not sure as to the root cause but this does appear to be due to an issue on that version of React Native (also was seeing it on 0.73.8). Is upgrading to a version >= 0.74 a possibility for you? (I did this testing on Android btw) |
I didn't upgrade my RN version, but downgrading these packages:
to
as per the demo, Seemed to resolve the issue. Thank you! |
Glad it worked! Still unsure as to the underlying cause though, on this commit here I'm using those same downgraded versions but am able to reproduce the error: https://github.com/open-telemetry/opentelemetry-demo/blob/a6ca5da1392ca78acdb55dfd2d4dc65aec1b4c77/src/reactnativeapp/package.json |
Sorry forgot about the poly fill for text-encoding when I did my last test, yes I was seeing the same as you To summarize:
There was quite a few changes between these versions (experimental/v0.52.0...experimental/v0.53.0) but I would guess the relevant changes happened in #4743 I wasn't able to narrow down the issue to a specific line but my guess is there isn't anything wrong with the implementation itself but rather comes down to APIs being used that weren't before that end up having some differing or flawed implementation in React Native. E.g. it looks like UInt8Array started being used and could run up against things like facebook/react-native#41079 where more poly fills may be needed I'll add a note to the demo app (open-telemetry/opentelemetry-demo#1781) and link to this issue, I think this falls in the bucket of the existing otel packages being possible to use in React Native but having to be careful of choosing the right versions / configurations and ultimately probably needing more explicit support for react native as a platform along with node and browser |
@jpmunz hmm, I think it might actually be the changes from #4895 that are causing this. We're serializing to In #4895 I added code to make a The error I get with I'll open a draft PR and will link it here. |
#5193 is my attempt at tackling this - when I turn on debug logging the logs say that the xhr request succeeds.
|
@pichlermarc awesome! Will take a look |
What happened?
Steps to Reproduce
Expected Result
Traces exported to collector endpoint in JSON format
Actual Result
Traces are being Base64 encoded via the
OTLPTraceExporter
, resulting in 400 response as endpoint expects JSONAdditional Details
When recreating this implementation of
@optentelemetry
in a React web app, traces are exported successfully in JSON format.@opentelemetry DiagConsoleLogger
indicates"stack":"ReferenceError: Property 'TextEncoder' doesn't exist\n at serializeRequest
.Importing the
text-encoding
polyfill clears this error and allows traces to be sent, but in the wrong format.OpenTelemetry Setup Code
package.json
Relevant log output
Operating System and Version
macOS 15.1
Runtime and Version
react-native 0.73.6
expo ~50.0.19
iPhone 16 Pro Simulator iOS 18.0
The text was updated successfully, but these errors were encountered: