{"id":21909206,"url":"https://github.com/somehowchris/rocket-tracing-fairing-example","last_synced_at":"2025-04-16T01:54:02.859Z","repository":{"id":38020130,"uuid":"445504191","full_name":"somehowchris/rocket-tracing-fairing-example","owner":"somehowchris","description":"An example of a fairing for rocket to use tracing (as this pops up at many places in dicussions and questions)","archived":false,"fork":false,"pushed_at":"2025-04-14T22:22:18.000Z","size":775,"stargazers_count":15,"open_issues_count":7,"forks_count":7,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-14T23:27:55.187Z","etag":null,"topics":["async","fairing","rocket","tokio","tokio-rs","tracing"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/somehowchris.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2022-01-07T11:51:59.000Z","updated_at":"2025-04-09T10:20:14.000Z","dependencies_parsed_at":"2023-11-17T20:29:02.365Z","dependency_job_id":"317412fb-ad4a-4f04-8c36-15ef160c70b3","html_url":"https://github.com/somehowchris/rocket-tracing-fairing-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/somehowchris%2Frocket-tracing-fairing-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/somehowchris%2Frocket-tracing-fairing-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/somehowchris%2Frocket-tracing-fairing-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/somehowchris%2Frocket-tracing-fairing-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/somehowchris","download_url":"https://codeload.github.com/somehowchris/rocket-tracing-fairing-example/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249183099,"owners_count":21226140,"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":["async","fairing","rocket","tokio","tokio-rs","tracing"],"created_at":"2024-11-28T17:15:58.028Z","updated_at":"2025-04-16T01:54:02.839Z","avatar_url":"https://github.com/somehowchris.png","language":"Rust","readme":"# Rocket Tracing Fairing Example\n[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/somehowchris/rocket-tracing-fairing-example)\n\nThis repository aims to give a short example of how you can add a Fairing to your Rocket for tracing and how to use it in requests.\n\u003e As Rocket currently doesn't implement this by default many have asked about implementing this. The actix-web tracing crate has been taken as a reference for the info span data\n\n\n## Logging\n\nThere 2 log types and 5 log levels you can configure at runtime.\n\n### Log Types\n\nLog types control how your output is formatted. They can be controlled via the environment variable `LOG_TYPE`.\n\nThe 2 types are:\n- `formatted`(default): a good choice for development\n![](./.static/formatted_output.png)\n- `json`: the propert choice if you are running your app in a production environment. If you are using [`vector`](https://vector.dev) you can check out `parse_json(...)`\n![](./.static/json_output.png)\n\n### Log Levels\n\nA lot of that code originated from a stable PR in rocket's repository [SergioBenites/Rocket#1579](https://github.com/SergioBenitez/Rocket/pull/1579) so thanks a lot to the people there and @jebrosen for the awesome work.\n\nYou can controll these with the environment variable `LOG_LEVEL`:\n- `critical`: Shows only critical logs\n- `support`: Shows logs to help out\n- `normal`: Includes all your default logs\n- `debug`: Shows debuging with tracing \n- `off`: Shows exactly nothing\n\n## Request-Tracing\n\nYou need to add the `enter` and `drop` statements inside your request as Rocket will not enter the span by default as it is currently not implemented in the base repository.\n\n### Names\n\nIf your parser follows the opentelemetry spec it will pick up the `otel.name` field as the name of the span which is a composit of the uri path and the method\n\n### Request Ids\n\nYou may be hosting rocket on a platform which provides it's own request ids via the `X-Request-Id` standard. If so rocket will pick this up and add it to the request span.\n\nIf not rocket will create a uuid, use that and append it as the `X-Request-Id` header to the response.\n\n### Why isn't this a crate?\n\nAs of right now I have has 4 people asking me the same question about tracing and rocket from difference perspektives within 4 days. If more people point out their desire to have a crate for this please open an issue and let the people vote.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsomehowchris%2Frocket-tracing-fairing-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsomehowchris%2Frocket-tracing-fairing-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsomehowchris%2Frocket-tracing-fairing-example/lists"}