{"id":49238834,"url":"https://github.com/makomweb/otel-sdk-react","last_synced_at":"2026-04-24T18:12:34.213Z","repository":{"id":349777575,"uuid":"1203793879","full_name":"makomweb/otel-sdk-react","owner":"makomweb","description":"Instrument your JavaScript application to provide traces following W3C reccommendations for propagating context.","archived":false,"fork":false,"pushed_at":"2026-04-07T15:20:58.000Z","size":66,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-04-07T15:22:55.562Z","etag":null,"topics":["javascript","library","npm","open-source","public","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@makomweb/otel-sdk-react","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/makomweb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-07T11:41:25.000Z","updated_at":"2026-04-07T15:21:45.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/makomweb/otel-sdk-react","commit_stats":null,"previous_names":["makomweb/otel-sdk-react"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/makomweb/otel-sdk-react","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makomweb%2Fotel-sdk-react","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makomweb%2Fotel-sdk-react/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makomweb%2Fotel-sdk-react/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makomweb%2Fotel-sdk-react/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/makomweb","download_url":"https://codeload.github.com/makomweb/otel-sdk-react/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makomweb%2Fotel-sdk-react/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32234973,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T13:21:15.438Z","status":"ssl_error","status_checked_at":"2026-04-24T13:21:15.005Z","response_time":64,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","library","npm","open-source","public","typescript"],"created_at":"2026-04-24T18:12:32.268Z","updated_at":"2026-04-24T18:12:34.207Z","avatar_url":"https://github.com/makomweb.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# otel-sdk-react\n\nSetup your JavaScript application to propagate context. This way your OpenTelemetry enabled application is able to \"connect\" traces between various services. \n\n## Features\n\n- **Web Trace Provider** - Distributed tracing with OTLP HTTP exporter  \n- **Metrics** - Application metrics with OTLP HTTP exporter  \n- **Logs** - Structured logging with OTLP HTTP exporter  \n- **Document Load Instrumentation** - Automatic page load tracing  \n- **Fetch Instrumentation** - Optional: Trace HTTP requests with W3C Trace Context propagation  \n- **TypeScript** - Full type safety (strict mode)  \n- **Lightweight** - Minimal dependencies, tree-shakeable\n\n## Installation\n\n```bash\nnpm install @makomweb/otel-sdk-react\n```\n\n**Peer dependencies** (should already be in your project):\n```json\n{\n  \"react\": \"\u003e=18.0.0\",\n  \"@opentelemetry/api\": \"\u003e=1.7.0\",\n  \"@opentelemetry/sdk-trace-web\": \"\u003e=1.17.0\",\n  \"@opentelemetry/sdk-metrics\": \"\u003e=1.17.0\",\n  \"@opentelemetry/sdk-logs\": \"\u003e=0.50.0\",\n  \"@opentelemetry/exporter-trace-otlp-http\": \"\u003e=0.43.0\",\n  \"@opentelemetry/exporter-metrics-otlp-http\": \"\u003e=0.43.0\",\n  \"@opentelemetry/exporter-logs-otlp-http\": \"\u003e=0.50.0\",\n  \"@opentelemetry/instrumentation\": \"\u003e=0.43.0\",\n  \"@opentelemetry/instrumentation-fetch\": \"\u003e=0.51.0\",\n  \"@opentelemetry/instrumentation-document-load\": \"\u003e=0.33.0\"\n}\n```\n\n## API Reference\n\n### `setupOTelSDK(collectorAddress: string)`\n\nInitialize OTEL SDK with Trace, Metric, and Log providers + Document Load instrumentation.\n\n```typescript\nimport { setupOTelSDK } from '@makomweb/otel-sdk-react';\n\nsetupOTelSDK('http://localhost:4318');\n```\n\n### `setupFetchInstrumentation(backendUrl: string)`\n\nTrace HTTP requests with W3C Trace Context propagation to your backend.\n\n```typescript\nimport { setupFetchInstrumentation } from '@makomweb/otel-sdk-react';\n\nsetupFetchInstrumentation('http://api.example.com');\n```\n\n## Usage\n\n### Basic Setup\n\nIn your `main.tsx` or `main.jsx`:\n\n```typescript\nimport React from 'react';\nimport ReactDOM from 'react-dom/client';\nimport { setupOTelSDK, setupFetchInstrumentation } from '@makomweb/otel-sdk-react';\n\nimport App from './App';\n\n// Initialize OTEL (required, before React renders)\nsetupOTelSDK('http://localhost:4318');\n\n// Optional: enable fetch tracing\nsetupFetchInstrumentation('http://localhost:8081');\n\nconst root = ReactDOM.createRoot(document.getElementById('root')!);\nroot.render(\n  \u003cReact.StrictMode\u003e\n    \u003cApp /\u003e\n  \u003c/React.StrictMode\u003e,\n);\n```\n\n### With Environment Variables\n\nCreate `.env.local`:\n```bash\nVITE_OTEL_COLLECTOR_ADDRESS=http://localhost:4318\nVITE_BACKEND_API_URL=http://localhost:8081\n```\n\nThen in `main.tsx`:\n```typescript\nsetupOTelSDK(import.meta.env.VITE_OTEL_COLLECTOR_ADDRESS);\nsetupFetchInstrumentation(import.meta.env.VITE_BACKEND_API_URL);\n```\n\n### Advanced: Config Module\n\nFor larger applications, organize configuration separately:\n\n```typescript\n// config.ts\nexport function getConfig() {\n  return {\n    otelCollectorAddress: import.meta.env.VITE_OTEL_COLLECTOR_ADDRESS || 'http://localhost:4318',\n    apiUrl: import.meta.env.VITE_BACKEND_API_URL || 'http://localhost:8081',\n  };\n}\n```\n\n```typescript\n// main.tsx\nimport { setupOTelSDK, setupFetchInstrumentation } from '@makomweb/otel-sdk-react';\nimport { getConfig } from './config';\n\nconst config = getConfig();\nsetupOTelSDK(config.otelCollectorAddress);\nsetupFetchInstrumentation(config.apiUrl);\n```\n\n## Troubleshooting\n\n### Spans not appearing in collector?\n\n1. **Verify setupOTelSDK() is called before React renders** (must be first in main.tsx)\n2. **Check collector is running**: `curl http://localhost:4318/v1/traces -X POST`\n3. **Check network in DevTools**: Look for requests to `/v1/traces` endpoint\n\n### FetchInstrumentation not tracing requests?\n\n1. **Verify setupFetchInstrumentation(backendUrl) is called**\n2. **Check backendUrl matches your API domain**\n3. **Check CORS headers**: Collector must accept cross-origin requests\n\n## Contributing\n\nSee [CONTRIBUTING.md](./CONTRIBUTING.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmakomweb%2Fotel-sdk-react","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmakomweb%2Fotel-sdk-react","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmakomweb%2Fotel-sdk-react/lists"}