Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ServerRequestCount = &view.View{ Name: "fortune/frontend/server/request_count", Description: "Count of HTTP requests started by Method", TagKeys: []tag.Key{ochttp.Method}, Measure: ochttp.ServerRequestCount, Aggregation: view.Count(), } ServerResponseCount = &view.View{ Name: "fortune/frontend/server/response_count", Description: "Server response count by status code, route and method", TagKeys: []tag.Key{ochttp.StatusCode, ochttp.KeyServerRoute, ochttp.Method}, Measure: ochttp.ServerLatency, Aggregation: view.Count(), } ServerLatency = &view.View{ Name: "fortune/frontend/server/response_latency", Description: "Server response distribution by status code, route and method", TagKeys: []tag.Key{ochttp.StatusCode, ochttp.KeyServerRoute, ochttp.Method}, Measure: ochttp.ServerLatency, Aggregation: ochttp.DefaultLatencyDistribution, } ServerResponseBytes = &view.View{ Name: "fortune/frontend/server/response_bytes", Description: "Size distribution of HTTP response body", TagKeys: []tag.Key{ochttp.StatusCode, ochttp.KeyServerRoute, ochttp.Method}, Measure: ochttp.ServerResponseBytes, Aggregation: ochttp.DefaultSizeDistribution, } ServerViews = []*view.View{ ServerRequestCount, ServerResponseCount, ServerLatency, ServerResponseBytes, } )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Name of the application.
Name string `json:"name"`
// Unique identifier for the current version of the application.
VersionID string `json:"versionId"`
// Git commit hash of the current application version.
VersionCommitHash string `json:"versionCommitHash"`
// Git commit date of the current application version.
VersionCommitDate string `json:"versionCommitDate"`
// Hostname of the machine or container where the application is running.
Hostname string `env:"HOSTNAME" json:"hostname"`
// The Google Cloud project ID associated with this application.
ProjectID string `json:"projectId"`
// The GCP zone where the application is deployed.
ZoneID string `json:"zoneId"`
// The unique instance ID of the VM or container running this application.
InstanceID string `json:"instanceId"`
// The service account being used by the application to authenticate with GCP services.
ServiceAccount string `json:"serviceAccount"`
// Name of the container running the application.
ContainerName string `env:"CONTAINER_NAME" json:"containerName"`
// Name of the Kubernetes cluster where the application is deployed.
ClusterName string `env:"CLUSTER_NAME" json:"clusterName"`
// Namespace in which the application is running within a Kubernetes cluster.
// This can also be retrieved from /var/run/secrets/kubernetes.io/serviceaccount/namespace.
NamespaceName string `env:"NAMESPACE_NAME" json:"namespaceName"`
// The main HTTP port on which the application listens for requests.
Port int `env:"PORT" envDefault:"8080" json:"port"`
// The port used for debugging (e.g., pprof, metrics, or other debug endpoints).
DebugPort int `env:"DEBUG_PORT" envDefault:"8081" json:"debugPort"`
// The logging level of the application (e.g., "info", "debug", "warn", "error").
LogLevel string `env:"LOG_LEVEL" envDefault:"info" json:"logLevel"`
// If true, disables the debug server.
DisableDebugServer bool `env:"DISABLE_DEBUG_SERVER" json:"disableDebugServer"`
// If true, disables the pprof debugging endpoint.
DisablePProfEndpoint bool `env:"DISABLE_DEBUG_SERVER_PPROF" json:"disablePprofEndpoint"`
// If true, disables the Prometheus metrics endpoint.
DisablePrometheusEndpoint bool `env:"DISABLE_DEBUG_SERVER_STATS" json:"disablePrometheusEndpoint"`
// If true, disables error reporting; locally this is always disabled.
DisableErrorReporting bool `env:"DISABLE_ERROR_REPORTING" json:"disableErrorReporting"`
// If true, enables CPU and memory profiling.
UseProfiler bool `env:"USE_PROFILER" json:"useProfiler"`
// If true, enables request tracing.
UseTracer bool `env:"USE_TRACER" json:"useTracer"`
// Maximum buffer size for storing trace spans before sending them.
// Default: 32 MB (33554432 bytes).
TraceSpansBufferMaxBytes int `env:"TRACE_SPANS_BUFFER_MAX_BYTES" envDefault:"33554432" json:"traceSpansBufferMaxBytes"`
// The fraction of requests to sample for tracing.
// Default: 0.01 (1% of requests will be traced).
TraceSamplerFraction float64 `env:"TRACE_SAMPLER_FRACTION" envDefault:"0.01" json:"traceSamplerFraction"`
// View (metrics) reporting period for Stackdriver monitoring.
// Due to Stackdriver limitations, statistics should be reported at least every minute.
// Default: 1 minute.
ViewReportingPeriod time.Duration `env:"VIEW_REPORTING_PERIOD" envDefault:"1m" json:"viewReportingPeriod"`
// Kubernetes service port (if running in a Kubernetes environment).
// This value is usually set by Kubernetes.
KubernetesServicePort int `env:"KUBERNETES_SERVICE_PORT" envDefault:"0" json:"-"`
// Database configuration settings.
DB database.DBConfig
}
func (Config) DebugServerAddress ¶
func (Config) IsRunningOnGCE ¶
func (Config) IsRunningOnKind ¶
func (Config) MustParseZapLogLevel ¶
func (Config) ServerAddress ¶
func (Config) ZapLogLevel ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) PanicHandler ¶
func (s *Server) PanicHandler() (_ http.HandlerFunc)
PanicHandler is invoked when some panic is caught by middleware.Panic.
Click to show internal directories.
Click to hide internal directories.