@@ -21,7 +21,6 @@ import {
2121 ATTR_SERVICE_VERSION ,
2222} from "@opentelemetry/semantic-conventions/incubating" ;
2323import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http" ;
24- import getLocalhost from "@/utils/Localhost" ;
2524import { useEffect , useState } from "react" ;
2625import {
2726 getDeviceId ,
@@ -30,10 +29,9 @@ import {
3029} from "react-native-device-info" ;
3130import { Platform } from "react-native" ;
3231import { SessionIdProcessor } from "@/utils/SessionIdProcessor" ;
32+ import getFrontendProxyURL from "@/utils/Settings" ;
3333
34- const Tracer = async ( ) => {
35- const localhost = await getLocalhost ( ) ;
36-
34+ export const setupTracerProvider = ( proxyURL : string ) => {
3735 // TODO Should add a resource detector for React Native that provides this automatically
3836 const resource = resourceFromAttributes ( {
3937 [ ATTR_SERVICE_NAME ] : "react-native-app" ,
@@ -49,23 +47,27 @@ const Tracer = async () => {
4947 // for React Native.
5048 // Alternatively could offer a TracerProvider that exposed a JS interface on top of the OTEL Android and Swift SDKS,
5149 // giving developers the option of collecting telemetry at the native mobile layer
52- const provider = new WebTracerProvider ( {
50+ return new WebTracerProvider ( {
5351 resource,
5452 spanProcessors : [
5553 new BatchSpanProcessor (
5654 new OTLPTraceExporter ( {
57- url : `http:// ${ localhost } : ${ process . env . EXPO_PUBLIC_FRONTEND_PROXY_PORT } /otlp-http/v1/traces` ,
55+ url : `${ proxyURL } /otlp-http/v1/traces` ,
5856 } ) ,
5957 {
6058 scheduledDelayMillis : 500 ,
6159 } ,
6260 ) ,
63-
6461 // TODO introduce a React Native session processor package that could be used here, taking into account mobile
6562 // specific considerations for the session such as putting the app into the background
6663 new SessionIdProcessor ( ) ,
6764 ] ,
6865 } ) ;
66+ }
67+
68+ const Tracer = async ( ) => {
69+ const proxyURL = await getFrontendProxyURL ( ) ;
70+ const provider = setupTracerProvider ( proxyURL ) ;
6971
7072 provider . register ( {
7173 propagator : new CompositePropagator ( {
0 commit comments