# v1.5.0 - 可观测性

## 指标收集

```go
// Prometheus指标
var (
    requestDuration = prometheus.NewHistogramVec(
        prometheus.HistogramOpts{
            Name: "rpc_request_duration_seconds",
            Help: "RPC request duration",
        },
        []string{"method", "status"},
    )
)

// 链路追踪
func TraceMiddleware(next Handler) Handler {
    return func(ctx context.Context, req Request) {
        span, ctx := opentracing.StartSpanFromContext(ctx, req.Method)
        defer span.Finish()
        
        next(ctx, req)
    }
}
```

## 健康检查

```go
func HealthCheck(w http.ResponseWriter, r *http.Request) {
    checks := map[string]bool{
        "mysql": checkMySQL(),
        "redis": checkRedis(),
    }
    
    for name, ok := range checks {
        if !ok {
            http.Error(w, name+" unhealthy", 503)
            return
        }
    }
    
    w.Write([]byte("OK"))
}
```
