fix: resolve all linting and formatting issues
- Fix error return value checks (errcheck) - Fix unused parameters by using underscore prefix - Add missing package comments to all packages - Fix context key type issue in middleware (use typed contextKey) - Replace deprecated trace.NewNoopTracerProvider with noop.NewTracerProvider - Fix embedded field selector in database client - Remove trailing whitespace - Remove revive linter (as requested) to avoid stuttering warnings for public API interfaces All linting and formatting checks now pass.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
// Package observability provides OpenTelemetry tracing setup and configuration.
|
||||
package observability
|
||||
|
||||
import (
|
||||
@@ -13,22 +14,23 @@ import (
|
||||
sdktrace "go.opentelemetry.io/otel/sdk/trace"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.26.0"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
"go.opentelemetry.io/otel/trace/noop"
|
||||
)
|
||||
|
||||
// Config holds OpenTelemetry configuration.
|
||||
type Config struct {
|
||||
Enabled bool
|
||||
ServiceName string
|
||||
Enabled bool
|
||||
ServiceName string
|
||||
ServiceVersion string
|
||||
Environment string
|
||||
OTLPEndpoint string
|
||||
Environment string
|
||||
OTLPEndpoint string
|
||||
}
|
||||
|
||||
// InitTracer initializes OpenTelemetry tracing.
|
||||
func InitTracer(ctx context.Context, cfg Config) (trace.TracerProvider, error) {
|
||||
if !cfg.Enabled {
|
||||
// Return a no-op tracer provider
|
||||
return trace.NewNoopTracerProvider(), nil
|
||||
return noop.NewTracerProvider(), nil
|
||||
}
|
||||
|
||||
// Create resource with service information
|
||||
@@ -91,4 +93,3 @@ func ShutdownTracer(ctx context.Context, tp trace.TracerProvider) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user