Documentation
¶
Index ¶
- Variables
- type Config
- type Metric
- type NoopTelemetry
- func (t *NoopTelemetry) GetServiceName() string
- func (t *NoopTelemetry) LogErrorln(args ...interface{})
- func (t *NoopTelemetry) LogFatalln(args ...interface{})
- func (t *NoopTelemetry) LogInfo(args ...interface{})
- func (t *NoopTelemetry) LogRequest() gin.HandlerFunc
- func (t *NoopTelemetry) MeterInt64Histogram(metric Metric) (metric.Int64Histogram, error)
- func (t *NoopTelemetry) MeterInt64UpDownCounter(metric Metric) (metric.Int64UpDownCounter, error)
- func (t *NoopTelemetry) MeterRequestDuration() gin.HandlerFunc
- func (t *NoopTelemetry) MeterRequestsInFlight() gin.HandlerFunc
- func (t *NoopTelemetry) Shutdown(ctx context.Context)
- func (t *NoopTelemetry) TraceStart(ctx context.Context, name string) (context.Context, trace.Span)
- type Telemetry
- func (t *Telemetry) GetServiceName() string
- func (t *Telemetry) LogErrorln(args ...interface{})
- func (t *Telemetry) LogFatalln(args ...interface{})
- func (t *Telemetry) LogInfo(args ...interface{})
- func (t *Telemetry) LogRequest() gin.HandlerFunc
- func (t *Telemetry) MeterInt64Histogram(metric Metric) (otelmetric.Int64Histogram, error)
- func (t *Telemetry) MeterInt64UpDownCounter(metric Metric) (otelmetric.Int64UpDownCounter, error)
- func (t *Telemetry) MeterRequestDuration() gin.HandlerFunc
- func (t *Telemetry) MeterRequestsInFlight() gin.HandlerFunc
- func (t *Telemetry) Shutdown(ctx context.Context)
- func (t *Telemetry) TraceStart(ctx context.Context, name string) (context.Context, oteltrace.Span)
- type TelemetryProvider
Constants ¶
This section is empty.
Variables ¶
var MetricRequestDurationMillis = Metric{
Name: "request_duration_millis",
Unit: "ms",
Description: "Measures the latency of HTTP requests processed by the server, in milliseconds.",
}
MetricRequestDurationMillis is a metric that measures the latency of HTTP requests processed by the server, in milliseconds.
var MetricRequestsInFlight = Metric{
Name: "requests_inflight",
Unit: "{count}",
Description: "Measures the number of requests currently being processed by the server.",
}
MetricRequestsInFlight is a metric that measures the number of requests currently being processed by the server.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { ServiceName string `env:"SERVICE_NAME" envDefault:"gotel"` ServiceVersion string `env:"SERVICE_VERSION" envDefault:"0.0.1"` Enabled bool `env:"TELEMETRY_ENABLED" envDefault:"true"` }
Config holds the configuration for the telemetry.
func NewConfigFromEnv ¶
NewConfigFromEnv creates a new telemetry config from the environment.
type NoopTelemetry ¶
type NoopTelemetry struct {
// contains filtered or unexported fields
}
NoopTelemetry is a no-op implementation of the TelemetryProvider interface.
func NewNoopTelemetry ¶
func NewNoopTelemetry(cfg Config) (*NoopTelemetry, error)
NewNoopTelemetry creates a new NoopTelemetry instance.
func (*NoopTelemetry) GetServiceName ¶
func (t *NoopTelemetry) GetServiceName() string
GetServiceName returns the service name.
func (*NoopTelemetry) LogErrorln ¶
func (t *NoopTelemetry) LogErrorln(args ...interface{})
LogErrorln logs nothing.
func (*NoopTelemetry) LogFatalln ¶
func (t *NoopTelemetry) LogFatalln(args ...interface{})
LogFatalln logs nothing, then exits.
func (*NoopTelemetry) LogInfo ¶
func (t *NoopTelemetry) LogInfo(args ...interface{})
LogInfo logs nothing.
func (*NoopTelemetry) LogRequest ¶
func (t *NoopTelemetry) LogRequest() gin.HandlerFunc
LogRequest is a no-op middleware.
func (*NoopTelemetry) MeterInt64Histogram ¶
func (t *NoopTelemetry) MeterInt64Histogram(metric Metric) (metric.Int64Histogram, error)
MeterInt64Histogram returns nil.
func (*NoopTelemetry) MeterInt64UpDownCounter ¶
func (t *NoopTelemetry) MeterInt64UpDownCounter(metric Metric) (metric.Int64UpDownCounter, error)
MeterInt64UpDownCounter returns nil.
func (*NoopTelemetry) MeterRequestDuration ¶
func (t *NoopTelemetry) MeterRequestDuration() gin.HandlerFunc
MeterRequestDuration is a no-op middleware.
func (*NoopTelemetry) MeterRequestsInFlight ¶
func (t *NoopTelemetry) MeterRequestsInFlight() gin.HandlerFunc
MeterRequestsInFlight is a no-op middleware.
func (*NoopTelemetry) Shutdown ¶
func (t *NoopTelemetry) Shutdown(ctx context.Context)
Shutdown does nothing.
func (*NoopTelemetry) TraceStart ¶
TraceStart returns the context and span unchanged.
type Telemetry ¶
type Telemetry struct {
// contains filtered or unexported fields
}
Telemetry is a wrapper around the OpenTelemetry logger, meter, and tracer.
func NewTelemetry ¶
NewTelemetry creates a new telemetry instance.
func (*Telemetry) GetServiceName ¶
GetServiceName returns the name of the service.
func (*Telemetry) LogErrorln ¶
func (t *Telemetry) LogErrorln(args ...interface{})
LogErrorln logs a message and then calls os.Exit(1).
func (*Telemetry) LogFatalln ¶
func (t *Telemetry) LogFatalln(args ...interface{})
LogFatalln logs a message and then calls os.Exit(1).
func (*Telemetry) LogInfo ¶
func (t *Telemetry) LogInfo(args ...interface{})
LogInfo logs a message at the info level.
func (*Telemetry) LogRequest ¶
func (t *Telemetry) LogRequest() gin.HandlerFunc
LogRequest is a gin middleware that logs the request path.
func (*Telemetry) MeterInt64Histogram ¶
func (t *Telemetry) MeterInt64Histogram(metric Metric) (otelmetric.Int64Histogram, error)
MeterInt64Histogram creates a new int64 histogram metric.
func (*Telemetry) MeterInt64UpDownCounter ¶
func (t *Telemetry) MeterInt64UpDownCounter(metric Metric) (otelmetric.Int64UpDownCounter, error)
MeterInt64UpDownCounter creates a new int64 up down counter metric.
func (*Telemetry) MeterRequestDuration ¶
func (t *Telemetry) MeterRequestDuration() gin.HandlerFunc
MeterRequestDuration is a gin middleware that captures the duration of the request.
func (*Telemetry) MeterRequestsInFlight ¶
func (t *Telemetry) MeterRequestsInFlight() gin.HandlerFunc
MeterRequestsInFlight is a gin middleware that captures the number of requests in flight.
type TelemetryProvider ¶
type TelemetryProvider interface { GetServiceName() string LogInfo(args ...interface{}) LogErrorln(args ...interface{}) LogFatalln(args ...interface{}) MeterInt64Histogram(metric Metric) (otelmetric.Int64Histogram, error) MeterInt64UpDownCounter(metric Metric) (otelmetric.Int64UpDownCounter, error) TraceStart(ctx context.Context, name string) (context.Context, oteltrace.Span) LogRequest() gin.HandlerFunc MeterRequestDuration() gin.HandlerFunc MeterRequestsInFlight() gin.HandlerFunc Shutdown(ctx context.Context) }
TelemetryProvider is an interface for the telemetry provider.