Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion example/bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions example/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { AppRegistry } from 'react-native';
import App from './src/App';
import { name as appName } from './app.json';
import 'react-native-url-polyfill/auto';

AppRegistry.registerComponent(appName, () => App);
1 change: 1 addition & 0 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"react": "^19.1.0",
"react-dom": "^19.1.0",
"react-native": "0.79.0",
"react-native-url-polyfill": "^2.0.0",
"react-native-web": "^0.20.0"
},
"devDependencies": {
Expand Down
12 changes: 12 additions & 0 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ export default function App() {
>
<Text>Increment counter</Text>
</Pressable>

<Pressable
style={{ padding: 16, backgroundColor: "lightgray", borderRadius: 8 }}
onPress={() => {
fetch("https://api.weatherstack.com/current?query=Portland")
.then((response) => response.json())
.then(data => console.log(data))
.catch(error => console.error(error))
}}
>
<Text>Fetch weather</Text>
</Pressable>
</View>
);
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
"@opentelemetry/core": "^2.0.0",
"@opentelemetry/exporter-metrics-otlp-http": "^0.200.0",
"@opentelemetry/exporter-trace-otlp-http": "^0.200.0",
"@opentelemetry/instrumentation": "^0.200.0",
"@opentelemetry/instrumentation-fetch": "^0.200.0",
"@opentelemetry/resources": "^2.0.0",
"@opentelemetry/sdk-metrics": "^2.0.0",
"@opentelemetry/sdk-trace-base": "^2.0.0",
Expand Down
11 changes: 11 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {
defaultResource,
resourceFromAttributes,
} from "@opentelemetry/resources";
import { registerInstrumentations } from "@opentelemetry/instrumentation";
import { FetchInstrumentation } from "@opentelemetry/instrumentation-fetch";
import {
MeterProvider,
PeriodicExportingMetricReader,
Expand Down Expand Up @@ -82,6 +84,15 @@ export function openTelemetrySDK(options: Options = {}) {
}),
});

registerInstrumentations({
instrumentations: [
new FetchInstrumentation({
propagateTraceHeaderCorsUrls: /.*/,
clearTimingResources: false,
}),
]
})

// Metrics

const logMetricReader = options.debug
Expand Down