{"id":21571079,"url":"https://github.com/treblle/treblle-go","last_synced_at":"2026-01-04T19:18:39.990Z","repository":{"id":42994218,"uuid":"406304473","full_name":"Treblle/treblle-go","owner":"Treblle","description":"The official Treblle SDK for Go. Seamlessly integrate Treblle to manage communication with your dashboard, send errors, and secure sensitive data.","archived":false,"fork":false,"pushed_at":"2025-02-20T10:36:32.000Z","size":52,"stargazers_count":13,"open_issues_count":3,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-24T13:01:39.581Z","etag":null,"topics":["api","api-monitoring","api-observability","backend","developer-tool","go","golang","logging","rest-api","restful-api","sdk","sdk-go","treblle","treblle-sdk"],"latest_commit_sha":null,"homepage":"https://www.treblle.com/","language":"Go","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/Treblle.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":"2021-09-14T09:27:46.000Z","updated_at":"2024-12-31T09:51:07.000Z","dependencies_parsed_at":"2024-03-13T15:46:53.347Z","dependency_job_id":null,"html_url":"https://github.com/Treblle/treblle-go","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Treblle%2Ftreblle-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Treblle%2Ftreblle-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Treblle%2Ftreblle-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Treblle%2Ftreblle-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Treblle","download_url":"https://codeload.github.com/Treblle/treblle-go/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248233935,"owners_count":21069493,"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":["api","api-monitoring","api-observability","backend","developer-tool","go","golang","logging","rest-api","restful-api","sdk","sdk-go","treblle","treblle-sdk"],"created_at":"2024-11-24T11:14:50.295Z","updated_at":"2026-01-04T19:18:39.973Z","avatar_url":"https://github.com/Treblle.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Treblle - API Intelligence Platform\n\n[![Treblle API Intelligence](https://github.com/user-attachments/assets/b268ae9e-7c8a-4ade-95da-b4ac6fce6eea)](https://treblle.com)\n\n[Website](http://treblle.com/) • [Documentation](https://docs.treblle.com/) • [Pricing](https://treblle.com/pricing)\n\nTreblle is an API intelligence platfom that helps developers, teams and organizations understand their APIs from a single integration point.\n\n---\n\n## Treblle Go Lang SDK\n\n### Requirements\n\n| Go Version | Support Status |\n|------------|----------------|\n| 1.23+      | Fully Supported |\n| 1.21 - 1.22 | Should work, not officially tested |\n| \u003c 1.21     | Not Supported |\n\n### Router \u0026 Framework Support\n\n| Router/Framework | Support Level | Native Integration |\n|------------------|---------------|-------------------|\n| **Standard Library** (`net/http`) | Fully Supported | Yes |\n| **Gin** | Fully Supported | Yes |\n| **Gorilla Mux** | ✅ Fully Supported | Yes |\n| **Chi** | Fully Supported | Yes |\n| **Echo** | Compatible | No |\n| **Fiber** | Compatible | No |\n| **Other Routers** | Compatible | No |\n\n## Installation\n\n### 1. Install the Package\n\n```bash\ngo get github.com/Treblle/treblle-go/v2\n```\n\n### 2. Get Your Credentials\nGet your SDK Token and API Key from the [Treblle Dashboard](https://platform.treblle.com).\n\n### 3. Configure Treblle\n\n```go\nimport (\n    \"github.com/treblle/treblle-go/v2\"\n)\n\nfunc main() {\n    treblle.Configure(treblle.Configuration{\n        SDK_TOKEN: \"your-treblle-sdk-token\",\n        API_KEY:   \"your-treblle-api-key\",\n    })\n\n    // Your API server setup\n    // ...\n}\n```\n\n### With Gin\n\nThe SDK provides native support for the Gin framework with automatic route pattern extraction:\n\n```go\nimport (\n    \"github.com/gin-gonic/gin\"\n    \"github.com/treblle/treblle-go/v2\"\n)\n\nfunc main() {\n    // Configure Treblle\n    treblle.Configure(treblle.Configuration{\n        SDK_TOKEN: \"your-treblle-sdk-token\",\n        API_KEY:   \"your-treblle-api-key\",\n    })\n\n    // Create Gin router\n    r := gin.Default()\n\n    // Apply Treblle middleware - route patterns are automatically extracted!\n    r.Use(treblle.GinMiddleware())\n\n    // Define your routes\n    r.GET(\"/users\", getUsersHandler)\n    r.GET(\"/users/:id\", getUserHandler)\n    r.POST(\"/users\", createUserHandler)\n\n    r.Run(\":8080\")\n}\n```\n\n### With Gorilla Mux\n\nThe SDK automatically extracts route patterns from Gorilla Mux:\n\n```go\nimport (\n    \"github.com/gorilla/mux\"\n    \"github.com/treblle/treblle-go\"\n)\n\nfunc main() {\n    // Configure Treblle\n    treblle.Configure(treblle.Configuration{\n        SDK_TOKEN: \"your-treblle-sdk-token\",\n        API_KEY:   \"your-treblle-api-key\",\n    })\n\n    // Create a new router\n    r := mux.NewRouter()\n    \n    // Apply the Treblle middleware to the router\n    r.Use(treblle.Middleware)\n\n    // Define your routes\n    r.HandleFunc(\"/users\", getUsersHandler).Methods(\"GET\")\n    r.HandleFunc(\"/users/{id}\", getUserHandler).Methods(\"GET\")\n    \n    http.ListenAndServe(\":8080\", r)\n}\n```\n\n### With Standard HTTP Package\n\nFor the standard library's HTTP server, use the `HandleFunc` helper to properly set route patterns:\n\n```go\nimport (\n    \"net/http\"\n    \"github.com/treblle/treblle-go\"\n)\n\nfunc main() {\n    // Configure Treblle\n    treblle.Configure(treblle.Configuration{\n        SDK_TOKEN: \"your-treblle-sdk-token\",\n        API_KEY:   \"your-treblle-api-key\",\n    })\n\n    // Create a new serve mux\n    mux := http.NewServeMux()\n    \n    // Define routes with route path patterns\n    mux.Handle(\"/users\", treblle.Middleware(treblle.HandleFunc(\"/users\", getUsersHandler)))\n    mux.Handle(\"/users/\", treblle.Middleware(treblle.HandleFunc(\"/users/:id\", getUserHandler)))\n    \n    http.ListenAndServe(\":8080\", mux)\n}\n```\n\n### With Other Router Libraries\n\nFor other router libraries, use the `WithRoutePath` function to set route patterns:\n\n```go\n// Example with a hypothetical router\nrouter.GET(\"/users/:id\", wrapHandler(treblle.WithRoutePath(\"/users/:id\", \n    treblle.Middleware(http.HandlerFunc(getUserHandler)))))\n```\n\n## Excluding Routes\n\nYou can configure Treblle to exclude specific routes from being tracked. This is useful for health checks, metrics endpoints, internal APIs, or any routes you don't want to monitor.\n\n### Basic Usage\n\n```go\ntreblle.Configure(treblle.Configuration{\n    SDK_TOKEN: \"your-treblle-sdk-token\",\n    API_KEY:   \"your-treblle-api-key\",\n    ExcludedRoutes: []string{\n        \"/health\",           // Exact match\n        \"/metrics\",          // Exact match\n        \"/admin/*\",          // Wildcard: matches all admin routes\n        \"/api/*/internal/*\", // Multiple wildcards\n    },\n})\n```\n\n### Pattern Types\n\n**Exact Match:**\n```go\nExcludedRoutes: []string{\"/health\", \"/status\", \"/readiness\"}\n```\n- Matches exactly `/health`, `/status`, and `/readiness`\n- Case-insensitive matching\n- Trailing slashes are normalized (`/health/` matches `/health`)\n\n**Simple Wildcard:**\n```go\nExcludedRoutes: []string{\"/admin/*\"}\n```\n- Matches `/admin/dashboard`, `/admin/users`, `/admin/users/123`, etc.\n- The `*` matches any segment and **all nested paths**\n- Perfect for excluding entire sections of your API\n\n**Multiple Wildcards:**\n```go\nExcludedRoutes: []string{\n    \"/api/*/internal/*\",\n    \"/v*/debug/*\",\n}\n```\n- Each `*` matches exactly one path segment\n- `/api/*/internal/*` matches `/api/v1/internal/debug`, `/api/v2/internal/metrics/detailed`, etc.\n- Provides fine-grained control over exclusions\n\n### Environment Variable\n\nYou can also set excluded routes via environment variable:\n```bash\nexport TREBLLE_EXCLUDED_ROUTES=\"/health,/metrics,/admin/*\"\n```\n\nThe environment variable uses comma-separated values and is loaded automatically if `ExcludedRoutes` is not set in the configuration.\n\n\n## Examples\n\nCheck the `examples` directory for complete example applications:\n\n- `gorilla_example`: Shows integration with Gorilla Mux\n- `standard_example`: Shows integration with the standard HTTP package\n\n\n## Getting Help\n\nIf you continue to experience issues:\n\n1. Enable `debug: true` and check console output\n2. Verify your SDK token and API key are correct in Treblle dashboard\n3. Test with a simple endpoint first\n4. Check [Treblle documentation](https://docs.treblle.com) for the latest updates\n5. Contact support at \u003chttps://treblle.com\u003e or email support@treblle.com\n\n## Support\n\nIf you have problems of any kind feel free to reach out via \u003chttps://treblle.com\u003e or email support@treblle.com and we'll do our best to help you out.\n\n## License\n\nCopyright 2025, Treblle Inc. Licensed under the MIT license:\nhttp://www.opensource.org/licenses/mit-license.php\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftreblle%2Ftreblle-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftreblle%2Ftreblle-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftreblle%2Ftreblle-go/lists"}