{"id":28589609,"url":"https://github.com/fast/fastrace-poem","last_synced_at":"2025-06-11T08:10:39.589Z","repository":{"id":283063033,"uuid":"950549962","full_name":"fast/fastrace-poem","owner":"fast","description":"A Poem middleware for propagating trace context for fastrace.","archived":false,"fork":false,"pushed_at":"2025-03-27T13:31:00.000Z","size":30,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-30T08:52:03.417Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fast.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":"2025-03-18T10:35:59.000Z","updated_at":"2025-03-27T13:31:05.000Z","dependencies_parsed_at":"2025-03-20T00:15:41.353Z","dependency_job_id":null,"html_url":"https://github.com/fast/fastrace-poem","commit_stats":null,"previous_names":["fast/fastrace-poem"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fast%2Ffastrace-poem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fast%2Ffastrace-poem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fast%2Ffastrace-poem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fast%2Ffastrace-poem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fast","download_url":"https://codeload.github.com/fast/fastrace-poem/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fast%2Ffastrace-poem/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259207802,"owners_count":22821766,"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":[],"created_at":"2025-06-11T08:10:37.345Z","updated_at":"2025-06-11T08:10:39.579Z","avatar_url":"https://github.com/fast.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fastrace-poem\n\n[![Crates.io](https://img.shields.io/crates/v/fastrace-poem.svg?style=flat-square\u0026logo=rust)](https://crates.io/crates/fastrace-poem)\n[![Documentation](https://img.shields.io/docsrs/fastrace-poem?style=flat-square\u0026logo=rust)](https://docs.rs/fastrace-poem/)\n[![MSRV 1.83.0](https://img.shields.io/badge/MSRV-1.83.0-green?style=flat-square\u0026logo=rust)](https://www.whatrustisit.com)\n[![CI Status](https://img.shields.io/github/actions/workflow/status/fast/fastrace-poem/ci.yml?style=flat-square\u0026logo=github)](https://github.com/fast/fastrace-poem/actions)\n[![License](https://img.shields.io/crates/l/fastrace-poem?style=flat-square)](https://github.com/fast/fastrace-poem/blob/main/LICENSE)\n\nDistributed tracing integration for [Poem](https://github.com/poem-web/poem) web framework with [fastrace](https://crates.io/crates/fastrace).\n\n## Overview\n\n`fastrace-poem` provides middleware for the Poem web framework to enable distributed tracing with automatic context propagation. This helps you track requests as they flow through your microservice architecture, giving you valuable insights for debugging, performance analysis, and system understanding.\n\n## What is Context Propagation?\n\nContext propagation is a fundamental concept in distributed tracing that enables the correlation of operations spanning multiple services. When a request moves from one service to another, trace context information needs to be passed along, ensuring that all operations are recorded as part of the same trace.\n\n`fastrace-poem` implements the [W3C Trace Context](https://www.w3.org/TR/trace-context/) standard for propagating trace information between services. This ensures compatibility with other tracing systems that follow the same standard.\n\n## Features\n\n- 🔄 **Automatic context propagation** via W3C traceparent headers.\n- 🌉 **Seamless integration** with Poem's middleware system.\n- 🔗 **Request tracing** with proper parent-child span relationships.\n- 📊 **Full compatibility** with fastrace's collection and reporting capabilities.\n\n## Installation\n\nAdd the following to your `Cargo.toml`:\n\n```toml\n[dependencies]\nfastrace = \"0.7\"\nfastrace-poem = \"0.1\"\n```\n\n## Usage\n\n### Server Integration\n\n```rust\nuse fastrace::collector::{Config, ConsoleReporter};\nuse fastrace_poem::FastraceMiddleware;\nuse poem::{get, handler, EndpointExt, Request, Response, Route, Server};\nuse poem::listener::TcpListener;\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c(), std::io::Error\u003e {\n    // Configure fastrace reporter.\n    fastrace::set_reporter(ConsoleReporter, Config::default());\n    \n    // Add the FastraceMiddleware to your routes.\n    let app = Route::new()\n        .at(\"/ping\", get(ping))\n        .with(FastraceMiddleware);\n    \n    Server::new(TcpListener::bind(\"0.0.0.0:8080\"))\n        .run(app)\n        .await?;\n    \n    fastrace::flush();\n\n    Ok(())\n}\n\n#[handler]\n#[fastrace::trace] // Trace individual handlers.\nfn ping() -\u003e Response {\n    Response::builder().body(\"pong\")\n}\n```\n\n### Client Usage with fastrace-reqwest\n\nTo propagate trace context from clients to your Poem service:\n\n```rust\nuse fastrace::prelude::*;\nuse reqwest::Client;\n\n#[fastrace::trace]\nasync fn send_request() {\n    let client = Client::new();\n    let response = client\n        .get(\"http://your-poem-service/endpoint\")\n        .headers(fastrace_reqwest::traceparent_headers()) // Adds traceparent header.\n        .send()\n        .await\n        .unwrap();\n    \n    // Process response...\n}\n```\n\n## How It Works\n\n1. When a request arrives, the middleware checks for a `traceparent` header.\n2. If present, it extracts the trace context; otherwise, it creates a new random context.\n3. A new root span is created for the request using the URI as the name.\n4. The request handler is executed within this span, and any child spans are properly linked.\n5. The trace is then collected by your configured fastrace reporter.\n\n### Complete Example\n\nCheck out the [examples directory](https://github.com/fast/fastrace-poem/tree/main/examples) for complete working examples showing:\n\n- `client.rs` - How to send requests with trace context.\n- `server.rs` - How to receive and process trace context using `fastrace-poem`.\n\nTo run the examples:\n\n```bash\n# First start the server\ncargo run --example server\n\n# Then in another terminal, run the client\ncargo run --example client\n```\n\n## License\n\nThis project is licensed under the [Apache-2.0](./LICENSE) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffast%2Ffastrace-poem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffast%2Ffastrace-poem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffast%2Ffastrace-poem/lists"}