Website • Documentation • Pricing
Treblle is an API intelligence platfom that helps developers, teams and organizations understand their APIs from a single integration point.
| Go Version | Support Status |
|---|---|
| 1.23+ | Fully Supported |
| 1.21 - 1.22 | Should work, not officially tested |
| < 1.21 | Not Supported |
| Router/Framework | Support Level | Native Integration |
|---|---|---|
Standard Library (net/http) |
Fully Supported | Yes |
| Gin | Fully Supported | Yes |
| Gorilla Mux | ✅ Fully Supported | Yes |
| Chi | Fully Supported | Yes |
| Echo | Compatible | No |
| Fiber | Compatible | No |
| Other Routers | Compatible | No |
go get github.com/Treblle/treblle-go/v2Get your SDK Token and API Key from the Treblle Dashboard.
import (
"github.com/treblle/treblle-go/v2"
)
func main() {
treblle.Configure(treblle.Configuration{
SDK_TOKEN: "your-treblle-sdk-token",
API_KEY: "your-treblle-api-key",
})
// Your API server setup
// ...
}The SDK provides native support for the Gin framework with automatic route pattern extraction:
import (
"github.com/gin-gonic/gin"
"github.com/treblle/treblle-go/v2"
)
func main() {
// Configure Treblle
treblle.Configure(treblle.Configuration{
SDK_TOKEN: "your-treblle-sdk-token",
API_KEY: "your-treblle-api-key",
})
// Create Gin router
r := gin.Default()
// Apply Treblle middleware - route patterns are automatically extracted!
r.Use(treblle.GinMiddleware())
// Define your routes
r.GET("/users", getUsersHandler)
r.GET("/users/:id", getUserHandler)
r.POST("/users", createUserHandler)
r.Run(":8080")
}The SDK automatically extracts route patterns from Gorilla Mux:
import (
"github.com/gorilla/mux"
"github.com/treblle/treblle-go"
)
func main() {
// Configure Treblle
treblle.Configure(treblle.Configuration{
SDK_TOKEN: "your-treblle-sdk-token",
API_KEY: "your-treblle-api-key",
})
// Create a new router
r := mux.NewRouter()
// Apply the Treblle middleware to the router
r.Use(treblle.Middleware)
// Define your routes
r.HandleFunc("/users", getUsersHandler).Methods("GET")
r.HandleFunc("/users/{id}", getUserHandler).Methods("GET")
http.ListenAndServe(":8080", r)
}For the standard library's HTTP server, use the HandleFunc helper to properly set route patterns:
import (
"net/http"
"github.com/treblle/treblle-go"
)
func main() {
// Configure Treblle
treblle.Configure(treblle.Configuration{
SDK_TOKEN: "your-treblle-sdk-token",
API_KEY: "your-treblle-api-key",
})
// Create a new serve mux
mux := http.NewServeMux()
// Define routes with route path patterns
mux.Handle("/users", treblle.Middleware(treblle.HandleFunc("/users", getUsersHandler)))
mux.Handle("/users/", treblle.Middleware(treblle.HandleFunc("/users/:id", getUserHandler)))
http.ListenAndServe(":8080", mux)
}For other router libraries, use the WithRoutePath function to set route patterns:
// Example with a hypothetical router
router.GET("/users/:id", wrapHandler(treblle.WithRoutePath("/users/:id",
treblle.Middleware(http.HandlerFunc(getUserHandler)))))You 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.
treblle.Configure(treblle.Configuration{
SDK_TOKEN: "your-treblle-sdk-token",
API_KEY: "your-treblle-api-key",
ExcludedRoutes: []string{
"/health", // Exact match
"/metrics", // Exact match
"/admin/*", // Wildcard: matches all admin routes
"/api/*/internal/*", // Multiple wildcards
},
})Exact Match:
ExcludedRoutes: []string{"/health", "/status", "/readiness"}- Matches exactly
/health,/status, and/readiness - Case-insensitive matching
- Trailing slashes are normalized (
/health/matches/health)
Simple Wildcard:
ExcludedRoutes: []string{"/admin/*"}- Matches
/admin/dashboard,/admin/users,/admin/users/123, etc. - The
*matches any segment and all nested paths - Perfect for excluding entire sections of your API
Multiple Wildcards:
ExcludedRoutes: []string{
"/api/*/internal/*",
"/v*/debug/*",
}- Each
*matches exactly one path segment /api/*/internal/*matches/api/v1/internal/debug,/api/v2/internal/metrics/detailed, etc.- Provides fine-grained control over exclusions
You can also set excluded routes via environment variable:
export TREBLLE_EXCLUDED_ROUTES="/health,/metrics,/admin/*"The environment variable uses comma-separated values and is loaded automatically if ExcludedRoutes is not set in the configuration.
Check the examples directory for complete example applications:
gorilla_example: Shows integration with Gorilla Muxstandard_example: Shows integration with the standard HTTP package
If you continue to experience issues:
- Enable
debug: trueand check console output - Verify your SDK token and API key are correct in Treblle dashboard
- Test with a simple endpoint first
- Check Treblle documentation for the latest updates
- Contact support at https://treblle.com or email [email protected]
If you have problems of any kind feel free to reach out via https://treblle.com or email [email protected] and we'll do our best to help you out.
Copyright 2025, Treblle Inc. Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
