{"id":31213805,"url":"https://github.com/celrenheit/flightrecordermw","last_synced_at":"2025-09-21T08:47:15.232Z","repository":{"id":231436095,"uuid":"773336664","full_name":"celrenheit/flightrecordermw","owner":"celrenheit","description":null,"archived":false,"fork":false,"pushed_at":"2024-03-17T12:03:58.000Z","size":6,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-04T02:46:08.068Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","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/celrenheit.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}},"created_at":"2024-03-17T11:52:49.000Z","updated_at":"2024-04-04T02:46:09.034Z","dependencies_parsed_at":"2024-04-04T02:56:14.960Z","dependency_job_id":null,"html_url":"https://github.com/celrenheit/flightrecordermw","commit_stats":null,"previous_names":["celrenheit/flightrecordermw"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/celrenheit/flightrecordermw","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/celrenheit%2Fflightrecordermw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/celrenheit%2Fflightrecordermw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/celrenheit%2Fflightrecordermw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/celrenheit%2Fflightrecordermw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/celrenheit","download_url":"https://codeload.github.com/celrenheit/flightrecordermw/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/celrenheit%2Fflightrecordermw/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276216327,"owners_count":25604726,"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","status":"online","status_checked_at":"2025-09-21T02:00:07.055Z","response_time":72,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-09-21T08:47:13.901Z","updated_at":"2025-09-21T08:47:15.222Z","avatar_url":"https://github.com/celrenheit.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flight Recorder middleware\n\nThis repo contains a middleware that uses the [FlightRecorder](https://pkg.go.dev/golang.org/x/exp/trace#FlightRecorder) from x/exp/trace to record trace data from a running Go application.\n\n## Usage\n\nTo setup the middleware, you need to provide a directory where the trace data will be stored, a FlightRecorder instance and a function that will be called for each request to decide if the trace data should be recorded.\n\n```go\nfr := trace.NewFlightRecorder()\nfr.Start()\n\nfrmw, err := flightrecordermw.New(\"/tmp\", fr, func(r *http.Request, stats flightrecordermw.Stats) bool {\n    return stats.Elapsed \u003e 100*time.Millisecond\n})\nif err != nil {\n    return err\n}\n```\n\nTo use the middleware, you need to wrap your handler with it.\n\n```go\nmux.Handle(\"/hello\", frmw.Middleware(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n    w.Write([]byte(\"Hello, World!\"))\n})))\n```\n\nThat's it!\n\n## Handler\n\nThe middleware also provides a handler that can be used to serve the trace data.\n\n```go\nmux.Handle(\"/traces/\", http.StripPrefix(\"/traces/\", frmw))\n```\n\nYou will find a listing of all the available traces in the directory provided when creating the middleware.\n\n## Example\n\nYou can find a complete example in the [example](./example) directory.\n\n## License (Apache 2)\n\nThis project is licensed under the Apache 2.0 License - see the [LICENSE](LICENSE) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcelrenheit%2Fflightrecordermw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcelrenheit%2Fflightrecordermw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcelrenheit%2Fflightrecordermw/lists"}