This piece was originally published on The New Stack.
In this post, we’re going to walk through how to instrument a React Native application to send data to any OpenTelemetry (OTel) backend over OTLP-HTTP. In a previous tutorial for CNCF, we showed how to do this using the OTel JavaScript (JS) packages. However, in this walkthrough, we’re using the open source Embrace React Native SDK for a few key reasons:
- The official OTel packages require some tip-toeing when integrating because React Native is not directly supported as a platform by the OpenTelemetry JS packages. The Embrace SDK was purpose-built to support React Native, which allows us to integrate the SDK without workarounds.
- The Embrace React Native SDK is built on top of Embrace’s native mobile SDKs for Android and iOS. This allows it to emit telemetry around crashes, memory issues, etc., that occur in the native code running in a mobile app. In other words, you get better visibility into mobile app issues by accessing context from both native and JS layers.
- Like the OTel SDK, the Embrace React Native SDK allows exporting data to any OTLP-HTTP endpoint. However, by also sending that data to Embrace, you can leverage the power of Embrace’s dashboard to gain further insights, which we’ll dig into at the end of this walkthrough.
For simplicity, we’ll focus on iOS in this walkthrough. This same flow will work for Android with some minor differences to the setup. (See Adding the React Native Embrace SDK and Getting Started with the Embrace Dashboard for more details.)