{"id":18217281,"url":"https://github.com/kuriocity/event-tracer","last_synced_at":"2026-05-10T03:43:02.967Z","repository":{"id":260884984,"uuid":"882618643","full_name":"kuriocity/event-tracer","owner":"kuriocity","description":"Tracing library for microservices","archived":false,"fork":false,"pushed_at":"2024-11-03T10:22:10.000Z","size":8,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-13T23:16:43.016Z","etag":null,"topics":["aws","gcp","library","messaging-queue","microservices","nodejs","tracing"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/kuriocity.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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}},"created_at":"2024-11-03T09:54:02.000Z","updated_at":"2024-11-03T10:28:04.000Z","dependencies_parsed_at":"2024-11-03T11:19:12.500Z","dependency_job_id":"df356787-484e-48ac-a2dc-765cc107ce37","html_url":"https://github.com/kuriocity/event-tracer","commit_stats":null,"previous_names":["kuriocity/event-tracer"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuriocity%2Fevent-tracer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuriocity%2Fevent-tracer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuriocity%2Fevent-tracer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuriocity%2Fevent-tracer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kuriocity","download_url":"https://codeload.github.com/kuriocity/event-tracer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247736971,"owners_count":20987708,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["aws","gcp","library","messaging-queue","microservices","nodejs","tracing"],"created_at":"2024-11-03T17:04:24.235Z","updated_at":"2026-05-10T03:43:02.934Z","avatar_url":"https://github.com/kuriocity.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 📦 Event Tracer Library\n\n\u003e **A plug-and-play tracing library for microservices**  \n\u003e Easily track events across distributed systems with support for Google Cloud Pub/Sub, AWS SQS, Kafka, and simple logging.\n\n## 🚀 Features\n\n- **Multi-Provider Support**: Works with Google Cloud Pub/Sub, AWS SQS, Kafka, and a logging provider for local dev.\n- **Vendor-Agnostic**: Use one interface to publish events, no matter the backend.\n- **Easy Configuration**: Enable or disable providers using environment variables.\n- **Extendable**: Easily add new providers with minimal code.\n\n## 🏗️ Setup\n\n1. **Clone the repository**\n   ```bash\n   git clone https://github.com/yourusername/event-tracer.git\n   cd event-tracer\n   ```\n\n2. **Install dependencies**\n   ```bash\n   npm install\n   ```\n\n3. **Configure providers**  \n   Copy `.env.example` to `.env`, then update the values for the providers you want to use:\n\n   ```plaintext\n   ENABLE_PUBSUB=true         # Set to true to enable Google Cloud Pub/Sub\n   ENABLE_SQS=false           # Set to true to enable AWS SQS\n   ENABLE_KAFKA=false         # Set to true to enable Kafka\n   KAFKA_BROKERS=localhost:9092\n   SQS_QUEUE_URL=https://sqs.region.amazonaws.com/123456789012/my-queue\n   ```\n\n   - **Enable only the providers you need**. For example, set `ENABLE_PUBSUB=true` to use Google Cloud Pub/Sub, or `ENABLE_KAFKA=true` for Kafka.\n   - If you’re not using a provider, you can skip its configuration.\n\n4. **Add providers in code**  \n   Open `src/index.js` and uncomment the providers you’ve enabled in the `.env` file:\n\n   ```javascript\n   const tracer = new Tracer();\n\n   if (process.env.ENABLE_PUBSUB === 'true') {\n       tracer.addProvider(new GoogleCloudPubSubProvider('ENTITY_EVENT_TRACING'));\n   }\n   if (process.env.ENABLE_SQS === 'true') {\n       tracer.addProvider(new AWSSQSProvider(process.env.SQS_QUEUE_URL));\n   }\n   if (process.env.ENABLE_KAFKA === 'true') {\n       tracer.addProvider(new KafkaProvider('tracing-events'));\n   }\n\n   tracer.addProvider(new LoggingProvider());  // Always include logging for local testing\n   ```\n\n5. **You're all set!** 🎉  \n   You’re now ready to start tracing events with a simple function call. \n\n## 🔧 Usage\n\nImport the tracer and start sending trace events with the following example:\n\n```javascript\nconst tracer = require('./src');\n\ntracer.traceEvent({\n    entityId: '12345',          // ID of the entity involved\n    timeline: Date.now(),       // Event timestamp\n    serviceName: 'UserService', // Service name triggering the event\n    data: { key: 'value' },     // Additional data related to the event\n    traces: ['init', 'save'],   // Steps in the trace\n    eventName: 'UserCreated'    // Event name\n});\n```\n\n### Sample Event Payload\n\nEach `traceEvent()` call sends a payload like this:\n\n```json\n{\n  \"entityId\": \"12345\",\n  \"timeline\": 1698765432,\n  \"serviceNameKeyword\": \"UserService\",\n  \"serviceNameText\": \"UserService\",\n  \"data\": { \"key\": \"value\" },\n  \"traces\": [\"init\", \"save\"],\n  \"eventName\": \"UserCreated\",\n  \"timeStamp\": 1698765432,\n  \"uuid\": \"unique-uuid-v4\"\n}\n```\n\n### Local Testing with Logging Provider\n\nFor local testing, the `LoggingProvider` outputs events directly to the console. You can disable all other providers in `.env` to use just this provider.\n\n## 📚 Adding a New Provider\n\nWant to add support for a different messaging service? Follow these steps:\n\n1. **Create a provider file**  \n   Create a new file in `src/providers`, e.g., `MyCustomProvider.js`.\n\n2. **Extend `BaseProvider` and implement `publish`**  \n   ```javascript\n   const BaseProvider = require('./BaseProvider');\n\n   class MyCustomProvider extends BaseProvider {\n       publish(payload) {\n           // Implement the logic to send `payload` to your custom backend\n           console.log(\"Publishing to MyCustomProvider\", payload);\n       }\n   }\n\n   module.exports = MyCustomProvider;\n   ```\n\n3. **Add the new provider in `index.js`**  \n   Import and add the provider as you did with other providers:\n   ```javascript\n   const MyCustomProvider = require('./providers/MyCustomProvider');\n   tracer.addProvider(new MyCustomProvider());\n   ```\n\n## 💻 Development Tips\n\n- **Console Testing**: Use the `LoggingProvider` to output all events to your console during development.\n- **Environment Isolation**: Configure different `.env` files for dev, staging, and production to easily switch providers.\n- **Automatic Provider Detection**: Consider scanning `src/providers` to auto-load providers without modifying `index.js` (optional).\n\n## 🌟 Contributing\n\nFeel free to fork the project, submit issues, and create pull requests to help improve this library for the community!\n\n## 📝 License\n\nThis project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkuriocity%2Fevent-tracer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkuriocity%2Fevent-tracer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkuriocity%2Fevent-tracer/lists"}