with one click
observability
// Observability best practices. Logging, metrics, tracing, alerting. Essential for production services. Use for any backend service.
// Observability best practices. Logging, metrics, tracing, alerting. Essential for production services. Use for any backend service.
C++ development best practices. Modern C++20/23, RAII, zero-overhead abstractions, safety. Use when writing C++ code.
Docker and container best practices. Multi-stage builds, security, optimization. Use when creating Dockerfiles.
Go development best practices. Idiomatic Go, error handling, concurrency patterns, testing. Use when writing Go code.
React Native development. Cross-platform code, native modules, performance. Use when building mobile apps.
Test-Driven Development workflow. Write failing test first, implement code to pass, then refactor. Essential for all languages: Go, TypeScript, C++, Python. Use before any implementation task.
Use when the user wants to commit, push, and open a pull request for the current changes. Stages relevant files, writes a descriptive commit message, pushes the branch, opens a PR against main, and posts an /oc review comment so opencode automatically reviews and approves if ready.
| name | observability |
| description | Observability best practices. Logging, metrics, tracing, alerting. Essential for production services. Use for any backend service. |
| compatibility | opencode |
Structured logging, metrics, distributed tracing, and alerting for production systems.
// Go: slog for structured logging
import "log/slog"
slog.Info("request completed",
"method", r.Method,
"path", r.URL.Path,
"duration_ms", duration.Milliseconds(),
"status", statusCode,
)
// Node.js: pino
import pino from 'pino';
const logger = pino({
level: 'info',
formatters: {
level: (label) => ({ level: label }),
},
});
// Prometheus metrics
import "github.com/prometheus/client_golang/prometheus"
var requestDuration = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Name: "http_request_duration_seconds",
Help: "HTTP request duration in seconds",
Buckets: []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5},
},
[]string{"method", "path", "status"},
)
var activeRequests = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "active_requests",
Help: "Number of active requests",
})
// OpenTelemetry
import "go.opentelemetry.io/otel"
import "go.opentelemetry.io/otel/trace"
func Handler(ctx context.Context, w http.ResponseWriter, r *http.Request) {
ctx, span := otel.Tracer("http").Start(ctx, r.URL.Path)
defer span.End()
// business logic
span.SetAttributes(
attribute.String("http.method", r.Method),
attribute.Int("http.status_code", statusCode),
)
}
// Liveness: process is running
// Readiness: service can handle requests
http.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
// check dependencies
if !db.Healthy() {
http.Error(w, "db unhealthy", http.StatusServiceUnavailable)
return
}
w.WriteHeader(http.StatusOK)
})