Documentation
¶
Index ¶
- Constants
- Variables
- func CaptureOutgoingAPIRequestRetryTotal(ctx context.Context, target, address, method string)
- func CaptureOutgoingAPIRequestTokenDuration(ctx context.Context, target, address, method string, latency time.Duration)
- func FormatMessageForLog(msg string) string
- func GenerateRequestContext(ctx context.Context, requestID, requestSource string, workflow Workflow, ...) context.Context
- func GenerateRequestContextForLayer(ctx context.Context, logLayer LogLayer) context.Context
- func GetDefaultLogLevel() string
- func GetLogLevel() string
- func GetSelectedLogLayers() string
- func GetSelectedWorkFlows() string
- func InitAuditLogger(disabled bool)
- func InitLogFormat(logFormat string) error
- func InitLogFormatter(formatter log.Formatter)
- func InitLogLevel(logLevel string) error
- func InitLogOutput(out io.Writer)
- func InitLoggingForDocker(logName, logFormat string) error
- func IsLevelEnabled(level log.Level) bool
- func IsLogLevelDebugOrHigher(level string) bool
- func ListLogLayers() []string
- func ListWorkflowTypes() []string
- func NewMetricsTransport(base http.RoundTripper, options ...MetricsTransportOption) http.RoundTripper
- func RedactBytes(line []byte) []byte
- func RedactString(line string) string
- func RedactedHTTPRequest(request *http.Request, requestBody []byte, driverName string, ...)
- func RedactedHTTPResponse(ctx context.Context, response *http.Response, responseBody []byte, ...)
- func SetContextLogLayer(ctx context.Context, l LogLayer) context.Context
- func SetContextWorkflow(ctx context.Context, w Workflow) context.Context
- func SetDefaultLogLevel(level string) error
- func SetLogLayers(layers string) error
- func SetWorkflows(wflows string) error
- type AuditEvent
- type AuditLogger
- type ConsoleHook
- type ContextBuilder
- func (cb ContextBuilder) BuildContext() context.Context
- func (cb ContextBuilder) BuildContextAndTelemetry() (context.Context, Recorder)
- func (cb ContextBuilder) BuildTelemetry() Recorder
- func (cb ContextBuilder) WithAddress(a ContextRequestAddress) ContextBuilder
- func (cb ContextBuilder) WithClient(c ContextRequestClient) ContextBuilder
- func (cb ContextBuilder) WithContext(childCtx context.Context) ContextBuilder
- func (cb ContextBuilder) WithIncomingAPIMetrics(client ContextRequestClient, method ContextRequestMethod) ContextBuilder
- func (cb ContextBuilder) WithLayer(l LogLayer) ContextBuilder
- func (cb ContextBuilder) WithMethod(m ContextRequestMethod) ContextBuilder
- func (cb ContextBuilder) WithOutgoingAPIMetrics(target ContextRequestTarget, address ContextRequestAddress, ...) ContextBuilder
- func (cb ContextBuilder) WithParent(parentCtx context.Context) ContextBuilder
- func (cb ContextBuilder) WithRoute(r ContextRequestRoute) ContextBuilder
- func (cb ContextBuilder) WithSource(s string) ContextBuilder
- func (cb ContextBuilder) WithTarget(t ContextRequestTarget) ContextBuilder
- func (cb ContextBuilder) WithWorkflow(w Workflow) ContextBuilder
- type ContextKey
- type ContextRequestAddress
- type ContextRequestClient
- type ContextRequestMethod
- type ContextRequestRoute
- type ContextRequestTarget
- type ContextSource
- type FileHook
- type JSONFormatter
- type LogEntry
- type LogFields
- type LogLayer
- type MetricsTransport
- type MetricsTransportOption
- type PlainTextFormatter
- type Recorder
- type Redactor
- type Telemeter
- type Workflow
- type WorkflowCategory
- type WorkflowOperation
Constants ¶
const ( ContextSourceUnknown string = "unknown" ContextSourceInternal string = "Internal" ContextSourceCRD string = "CRD" ContextSourceREST string = "REST" ContextSourceK8S string = "Kubernetes" ContextSourceDocker string = "Docker" ContextSourceCSI string = "CSI" ContextSourcePeriodic string = "Periodic" )
Context Request Source Values are stock values that should be used with incoming and outgoing requests to identify the source of the context and request in Trident. Custom source values can also be used based on the source system or component, but generally these should cover most use cases.
const ( ContextRequestAddressUnknown ContextRequestAddress = "unknown" ContextRequestRouteUnknown ContextRequestRoute = "unknown" ContextRequestMethodUnknown ContextRequestMethod = "unknown" )
Misc. context request values. These can be used with incoming and outgoing requests.
const ( LogSource = "logSource" AuditRESTAccess = AuditEvent("rest") AuditGRPCAccess = AuditEvent("csi") AuditDockerAccess = AuditEvent("docker") )
const ( LogLayerSeparator = "," LogLayerCore = LogLayer("core") LogLayerCoreCache = LogLayer("core_cache") LogLayerCSIFrontend = LogLayer("csi_frontend") LogLayerRESTFrontend = LogLayer("rest_frontend") LogLayerCRDFrontend = LogLayer("crd_frontend") LogLayerDockerFrontend = LogLayer("docker_frontend") LogLayerMetricsFrontend = LogLayer("metrics_frontend") LogLayerPersistentStore = LogLayer("persistent_store") LogLayerANFNASDriver = LogLayer(AzureNASStorageDriverName) LogLayerSolidfireDriver = LogLayer(SolidfireSANStorageDriverName) LogLayerGCNVNASDriver = LogLayer(GCNVNASStorageDriverName) LogLayerOntapNASDriver = LogLayer(OntapNASStorageDriverName) LogLayerOntapNASFlexgroupDriver = LogLayer(OntapNASFlexGroupStorageDriverName) LogLayerOntapNASQtreeDriver = LogLayer(OntapNASQtreeStorageDriverName) LogLayerOntapSANDriver = LogLayer(OntapSANStorageDriverName) LogLayerOntapSANEcoDriver = LogLayer(OntapSANEconomyStorageDriverName) LogLayerOntapAPI = LogLayer("ontap_api") LogLayerKubernetesAPI = LogLayer("kubernetes_api") LogLayerFakeDriver = LogLayer(FakeStorageDriverName) LogLayerUtils = LogLayer("utils") LogLayerAutogrow = LogLayer("autogrow") LogLayerAll = LogLayer("all") LogLayerNone = LogLayer("none") )
const ( UseDefault = iota Trace )
const ( LogRoot = "/var/log/" + config.OrchestratorName LogRotationThreshold = 10485760 // 10 MB MaxLogEntryLength = 64000 RandomLogcheckEnvVar = "LOGROTATE_FREQUENCY" )
const ( TextFormat = "text" JSONFormat = "json" )
const ( WorkflowFlagSeparator = ":" CategoryCore = WorkflowCategory("core") CategoryCRDController = WorkflowCategory("crd_controller") CategoryCR = WorkflowCategory("cr") CategoryStorageClient = WorkflowCategory("storage_client") CategoryPlugin = WorkflowCategory("plugin") CategoryVolume = WorkflowCategory("volume") CategoryStorageClass = WorkflowCategory("storage_class") CategoryNode = WorkflowCategory("node") CategoryBackend = WorkflowCategory("backend") CategorySnapshot = WorkflowCategory("snapshot") CategoryGroupControllerServer = WorkflowCategory("group_controller_server") CategoryControllerServer = WorkflowCategory("controller_server") CategoryNodeServer = WorkflowCategory("node_server") CategoryIdentityServer = WorkflowCategory("identity_server") CategoryGRPC = WorkflowCategory("grpc") CategoryTridentREST = WorkflowCategory("trident_rest") CategoryK8sClient = WorkflowCategory("k8s_client") CategoryNone = WorkflowCategory("none") OpBootstrap = WorkflowOperation("bootstrap") OpVersion = WorkflowOperation("version") OpNodeReconcile = WorkflowOperation("node_reconcile") OpBackendReconcile = WorkflowOperation("backend_reconcile") OpReconcile = WorkflowOperation("reconcile") OpTrace = WorkflowOperation("trace") OpLogger = WorkflowOperation("logger") OpActivate = WorkflowOperation("activate") OpDeactivate = WorkflowOperation("deactivate") OpCreate = WorkflowOperation("create") OpGet = WorkflowOperation("get") OpGetInfo = WorkflowOperation("get_info") OpGetStats = WorkflowOperation("get_stats") OpGetPath = WorkflowOperation("get_path") OpList = WorkflowOperation("list") OpUpdate = WorkflowOperation("update") OpDelete = WorkflowOperation("delete") OpUpgrade = WorkflowOperation("upgrade") OpClone = WorkflowOperation("clone") OpCloneFrom = WorkflowOperation("clone_from") OpImport = WorkflowOperation("import") OpResize = WorkflowOperation("resize") OpMount = WorkflowOperation("mount") OpUnmount = WorkflowOperation("unmount") OpGetCapabilties = WorkflowOperation("get_capabilities") OpProbe = WorkflowOperation("probe") OpGetResponse = WorkflowOperation("get_response") OpPublish = WorkflowOperation("publish") OpUnpublish = WorkflowOperation("unpublish") OpStage = WorkflowOperation("stage") OpUnstage = WorkflowOperation("unstage") OpHealISCSI = WorkflowOperation("heal_iscsi") OpHealNVMe = WorkflowOperation("heal_nvme") OpReconcilePubs = WorkflowOperation("reconcile_publications") OpTraceFactory = WorkflowOperation("trace_factory") OpTraceAPI = WorkflowOperation("trace_api") OpInit = WorkflowOperation("init") OpNone = WorkflowOperation("none") OpAll = WorkflowOperation("all") )
Variables ¶
var ( // Allowable workflows for trace logging. WorkflowCoreBootstrap = Workflow{CategoryCore, OpBootstrap} WorkflowCoreVersion = Workflow{CategoryCore, OpVersion} WorkflowCoreInit = Workflow{CategoryCore, OpInit} WorkflowCoreNodeReconcile = Workflow{CategoryCore, OpNodeReconcile} WorkflowCoreBackendReconcile = Workflow{CategoryCore, OpBackendReconcile} WorkflowGRPCTrace = Workflow{CategoryGRPC, OpTrace} WorkflowTridentRESTLogger = Workflow{CategoryTridentREST, OpLogger} WorkflowK8sClientFactory = Workflow{CategoryK8sClient, OpTraceFactory} WorkflowK8sClientAPI = Workflow{CategoryK8sClient, OpTraceAPI} WorkflowCRDControllerCreate = Workflow{CategoryCRDController, OpCreate} WorkflowCRReconcile = Workflow{CategoryCR, OpReconcile} WorkflowStorageClientCreate = Workflow{CategoryStorageClient, OpCreate} WorkflowPluginCreate = Workflow{CategoryPlugin, OpCreate} WorkflowPluginList = Workflow{CategoryPlugin, OpList} WorkflowPluginGet = Workflow{CategoryPlugin, OpGet} WorkflowPluginActivate = Workflow{CategoryPlugin, OpActivate} WorkflowPluginDeactivate = Workflow{CategoryPlugin, OpDeactivate} WorkflowVolumeCreate = Workflow{CategoryVolume, OpCreate} WorkflowVolumeUpdate = Workflow{CategoryVolume, OpUpdate} WorkflowVolumeUpgrade = Workflow{CategoryVolume, OpUpgrade} WorkflowVolumeGet = Workflow{CategoryVolume, OpGet} WorkflowVolumeGetStats = Workflow{CategoryVolume, OpGetStats} WorkflowVolumeGetPath = Workflow{CategoryVolume, OpGetPath} WorkflowVolumeList = Workflow{CategoryVolume, OpList} WorkflowVolumeDelete = Workflow{CategoryVolume, OpDelete} WorkflowVolumeClone = Workflow{CategoryVolume, OpClone} WorkflowVolumeImport = Workflow{CategoryVolume, OpImport} WorkflowVolumeResize = Workflow{CategoryVolume, OpResize} WorkflowVolumeMount = Workflow{CategoryVolume, OpMount} WorkflowVolumeUnmount = Workflow{CategoryVolume, OpUnmount} WorkflowVolumeGetCapabilities = Workflow{CategoryVolume, OpGetCapabilties} WorkflowStorageClassCreate = Workflow{CategoryStorageClass, OpCreate} WorkflowStorageClassGet = Workflow{CategoryStorageClass, OpGet} WorkflowStorageClassUpdate = Workflow{CategoryStorageClass, OpUpdate} WorkflowStorageClassList = Workflow{CategoryStorageClass, OpList} WorkflowStorageClassDelete = Workflow{CategoryStorageClass, OpDelete} WorkflowGroupSnapshotCreate = Workflow{CategoryGroupControllerServer, OpCreate} WorkflowGroupSnapshotGet = Workflow{CategoryGroupControllerServer, OpGet} WorkflowGroupSnapshotDelete = Workflow{CategoryGroupControllerServer, OpDelete} WorkflowNodeCreate = Workflow{CategoryNode, OpCreate} WorkflowNodeGet = Workflow{CategoryNode, OpGet} WorkflowNodeGetInfo = Workflow{CategoryNode, OpGetInfo} WorkflowNodeGetCapabilities = Workflow{CategoryNode, OpGetCapabilties} WorkflowNodeGetResponse = Workflow{CategoryNode, OpGetResponse} WorkflowNodeUpdate = Workflow{CategoryNode, OpUpdate} WorkflowNodeList = Workflow{CategoryNode, OpList} WorkflowNodeDelete = Workflow{CategoryNode, OpDelete} WorkflowIdentityProbe = Workflow{CategoryIdentityServer, OpProbe} WorkflowIdentityGetInfo = Workflow{CategoryIdentityServer, OpGetInfo} WorkflowIdentityGetCapabilities = Workflow{CategoryIdentityServer, OpGetCapabilties} WorkflowBackendCreate = Workflow{CategoryBackend, OpCreate} WorkflowBackendDelete = Workflow{CategoryBackend, OpDelete} WorkflowBackendGet = Workflow{CategoryBackend, OpGet} WorkflowBackendUpdate = Workflow{CategoryBackend, OpUpdate} WorkflowBackendList = Workflow{CategoryBackend, OpList} WorkflowSnapshotCreate = Workflow{CategorySnapshot, OpCreate} WorkflowSnapshotDelete = Workflow{CategorySnapshot, OpDelete} WorkflowSnapshotGet = Workflow{CategorySnapshot, OpGet} WorkflowSnapshotUpdate = Workflow{CategorySnapshot, OpUpdate} WorkflowSnapshotList = Workflow{CategorySnapshot, OpList} WorkflowSnapshotCloneFrom = Workflow{CategorySnapshot, OpCloneFrom} WorkflowControllerPublish = Workflow{CategoryControllerServer, OpPublish} WorkflowControllerUnpublish = Workflow{CategoryControllerServer, OpUnpublish} WorkflowControllerGetCapabilities = Workflow{CategoryControllerServer, OpGetCapabilties} WorkflowGroupControllerGetCapabilities = Workflow{CategoryGroupControllerServer, OpGetCapabilties} WorkflowNodeStage = Workflow{CategoryNodeServer, OpStage} WorkflowNodeUnstage = Workflow{CategoryNodeServer, OpUnstage} WorkflowNodePublish = Workflow{CategoryNodeServer, OpPublish} WorkflowNodeUnpublish = Workflow{CategoryNodeServer, OpUnpublish} WorkflowNodeHealISCSI = Workflow{CategoryNodeServer, OpHealISCSI} WorkflowNodeHealNVMe = Workflow{CategoryNodeServer, OpHealNVMe} WorkflowNodeReconcilePubs = Workflow{CategoryNodeServer, OpReconcilePubs} WorkflowNone = Workflow{CategoryNone, OpNone} WorkflowTypes = []Workflow{ WorkflowCoreBootstrap, WorkflowCoreVersion, WorkflowCoreInit, WorkflowCoreNodeReconcile, WorkflowGRPCTrace, WorkflowTridentRESTLogger, WorkflowCRDControllerCreate, WorkflowCRReconcile, WorkflowStorageClientCreate, WorkflowPluginCreate, WorkflowPluginList, WorkflowPluginGet, WorkflowPluginActivate, WorkflowPluginDeactivate, WorkflowVolumeCreate, WorkflowVolumeUpdate, WorkflowVolumeUpgrade, WorkflowVolumeGet, WorkflowVolumeGetStats, WorkflowVolumeGetPath, WorkflowVolumeList, WorkflowVolumeDelete, WorkflowVolumeClone, WorkflowVolumeImport, WorkflowVolumeResize, WorkflowVolumeMount, WorkflowVolumeUnmount, WorkflowVolumeGetCapabilities, WorkflowStorageClassCreate, WorkflowStorageClassGet, WorkflowStorageClassUpdate, WorkflowStorageClassList, WorkflowStorageClassDelete, WorkflowNodeCreate, WorkflowNodeGet, WorkflowNodeGetInfo, WorkflowNodeGetCapabilities, WorkflowNodeGetResponse, WorkflowNodeUpdate, WorkflowNodeList, WorkflowNodeDelete, WorkflowBackendCreate, WorkflowBackendDelete, WorkflowBackendGet, WorkflowBackendUpdate, WorkflowBackendList, WorkflowSnapshotCreate, WorkflowSnapshotDelete, WorkflowSnapshotGet, WorkflowSnapshotUpdate, WorkflowSnapshotList, WorkflowSnapshotCloneFrom, WorkflowControllerPublish, WorkflowControllerUnpublish, WorkflowControllerGetCapabilities, WorkflowNodeStage, WorkflowNodeUnstage, WorkflowNodePublish, WorkflowNodeUnpublish, WorkflowK8sClientFactory, WorkflowK8sClientAPI, } )
var Layers = []LogLayer{ LogLayerCore, LogLayerCSIFrontend, LogLayerRESTFrontend, LogLayerCRDFrontend, LogLayerDockerFrontend, LogLayerPersistentStore, LogLayerANFNASDriver, LogLayerSolidfireDriver, LogLayerOntapNASDriver, LogLayerOntapNASFlexgroupDriver, LogLayerOntapNASQtreeDriver, LogLayerOntapSANDriver, LogLayerOntapSANEcoDriver, LogLayerFakeDriver, LogLayerAutogrow, LogLayerAll, }
Functions ¶
func CaptureOutgoingAPIRequestRetryTotal ¶
CaptureOutgoingAPIRequestRetryTotal records the total number of outgoing API requests that were retried. This should only be used in cases when it is already known that a retry has occurred.
func CaptureOutgoingAPIRequestTokenDuration ¶
func CaptureOutgoingAPIRequestTokenDuration(ctx context.Context, target, address, method string, latency time.Duration)
CaptureOutgoingAPIRequestTokenDuration records how long outgoing API requests waited for a rate limit token or lock. This does not include time spent on the wire. Sub-millisecond waits are ignored — they represent uncontended overhead, not real queuing pressure.
func FormatMessageForLog ¶
FormatMessageForLog capitalizes the first letter of the string, and adds punctuation.
func GenerateRequestContext ¶
func GenerateRequestContextForLayer ¶
GenerateRequestContextForLayer generates a new context for the specified logging layer.
func GetDefaultLogLevel ¶
func GetDefaultLogLevel() string
func GetLogLevel ¶
func GetLogLevel() string
func GetSelectedLogLayers ¶
func GetSelectedLogLayers() string
func GetSelectedWorkFlows ¶
func GetSelectedWorkFlows() string
func InitAuditLogger ¶
func InitAuditLogger(disabled bool)
func InitLogFormat ¶
InitLogFormat configures the log format, allowing a choice of text or JSON.
func InitLogFormatter ¶
func InitLogLevel ¶
InitLogLevel configures the logging level using the flag value (trace, debug, info, warn, error, fatal).
func InitLogOutput ¶
func InitLoggingForDocker ¶
InitLoggingForDocker configures logging for nDVP. Logs are written both to a log file and stdout/stderr. Since logrus doesn't support multiple writers, each log stream is implemented as a hook.
func IsLevelEnabled ¶
func IsLogLevelDebugOrHigher ¶
func ListLogLayers ¶
func ListLogLayers() []string
func ListWorkflowTypes ¶
func ListWorkflowTypes() []string
func NewMetricsTransport ¶
func NewMetricsTransport( base http.RoundTripper, options ...MetricsTransportOption, ) http.RoundTripper
NewMetricsTransport creates a new MetricsTransport with the given options. If no options are provided, it defaults the target to ContextRequestTargetUnknown.
func RedactBytes ¶
RedactBytes applies all configured logging redaction patterns to raw bytes.
func RedactString ¶
RedactString applies all configured logging redaction patterns to a string.
func RedactedHTTPRequest ¶
func RedactedHTTPResponse ¶
func SetContextLogLayer ¶
SetContextLogLayer sets the associated log layer of the context. This WILL replace the log layer if it already exists. This will replace the log layer in the RequestContextOptions stored in the context.
func SetContextWorkflow ¶
SetContextWorkflow sets the workflow type of the context. This WILL replace the workflow type if it already exists.
func SetDefaultLogLevel ¶
func SetLogLayers ¶
func SetWorkflows ¶
SetWorkflows takes a list of workflow categories and workflow operations for which to enable trace logging for. An example of such a list is: controller:publish,unpublish;volume:create,delete What this example would do is to enable trace logging for the publish and unpublish operations within the controller category. Then, it would enable trace logging for the create and delete operations within the volume category. NOTE: The separators on which the string is split into its constituent parts (different sets of categories and their operations) are defined at the top of this file. If they are changed, this example will would need to be updated.
Types ¶
type AuditEvent ¶
type AuditEvent string
type AuditLogger ¶
type AuditLogger interface {
Log(ctx context.Context, event AuditEvent, fields LogFields, message string)
Logln(ctx context.Context, event AuditEvent, fields LogFields, message string)
Logf(ctx context.Context, event AuditEvent, fields LogFields, format string, args ...interface{})
}
func Audit ¶
func Audit() AuditLogger
type ConsoleHook ¶
type ConsoleHook struct {
// contains filtered or unexported fields
}
ConsoleHook sends log entries to stdout.
func NewConsoleHook ¶
func NewConsoleHook(logFormat string) (*ConsoleHook, error)
NewConsoleHook creates a new log hook for writing to stdout/stderr.
func (*ConsoleHook) Levels ¶
func (hook *ConsoleHook) Levels() []log.Level
type ContextBuilder ¶
ContextBuilder builds a context with various context values and telemeters. Each method returns a new ContextBuilder, allowing for chaining.
func NewContextBuilder ¶
func NewContextBuilder(ctx context.Context) ContextBuilder
NewContextBuilder creates a new ContextBuilder with the supplied context as the base. This context is maintained as the parent context for all subsequent additions to maintain proper context chaining and cancellation. If a nil context is supplied, context.TODO() is used.
func (ContextBuilder) BuildContext ¶
func (cb ContextBuilder) BuildContext() context.Context
BuildContext builds and returns the context without any Recorder.
func (ContextBuilder) BuildContextAndTelemetry ¶
func (cb ContextBuilder) BuildContextAndTelemetry() (context.Context, Recorder)
BuildContextAndTelemetry builds the context along with a Recorder to capture all supplied Telemetry metrics. If no Telemeter is set, the returned Recorder will be a NOP.
func (ContextBuilder) BuildTelemetry ¶
func (cb ContextBuilder) BuildTelemetry() Recorder
BuildTelemetry builds and returns a set a Recorder to capture all supplied Telemetry metrics. If no Telemeter is set, the returned Recorder will be a NOP.
func (ContextBuilder) WithAddress ¶
func (cb ContextBuilder) WithAddress(a ContextRequestAddress) ContextBuilder
func (ContextBuilder) WithClient ¶
func (cb ContextBuilder) WithClient(c ContextRequestClient) ContextBuilder
WithClient sets the ContextRequestClient in the context. This should be set to identify the client making the request, typically in frontend Layers.
func (ContextBuilder) WithContext ¶
func (cb ContextBuilder) WithContext(childCtx context.Context) ContextBuilder
WithContext merges the supplied context into the existing context. It does not change the existing context's cancellation or deadline, only its values. This will merge all values from the supplied context. Use at your discretion.
func (ContextBuilder) WithIncomingAPIMetrics ¶
func (cb ContextBuilder) WithIncomingAPIMetrics(client ContextRequestClient, method ContextRequestMethod) ContextBuilder
WithIncomingAPIMetrics sets the client and method label values in the context and registers an IncomingAPITelemeter that will record in-flight count and request duration when the returned Recorder is called. It should be used for all incoming API entry points. Any previously assigned client or method will be overridden in the context by calling this method.
func (ContextBuilder) WithLayer ¶
func (cb ContextBuilder) WithLayer(l LogLayer) ContextBuilder
WithLayer sets the LogLayer in the context.
func (ContextBuilder) WithMethod ¶
func (cb ContextBuilder) WithMethod(m ContextRequestMethod) ContextBuilder
func (ContextBuilder) WithOutgoingAPIMetrics ¶
func (cb ContextBuilder) WithOutgoingAPIMetrics(target ContextRequestTarget, address ContextRequestAddress, method ContextRequestMethod) ContextBuilder
WithOutgoingAPIMetrics sets the target, address, and method values in the context and adds the outgoing API telemeters to gather metrics for the request. This should be used for all outgoing API requests. This can be safely used with 1-many other Telemeters. Any previously assigned target, address, or method will be overridden in the context by calling this method.
func (ContextBuilder) WithParent ¶
func (cb ContextBuilder) WithParent(parentCtx context.Context) ContextBuilder
WithParent sets a new parent context, adopting a new cancellation and deadline for the existing context. This is similar to WithContext, but the parameter name emphasizes that the supplied context is intended to be the parent of the existing context. It does not overrule the existing context's values. Prefer to supply the parent context at the creation of the ContextBuilder via NewContextBuilder when possible.
func (ContextBuilder) WithRoute ¶
func (cb ContextBuilder) WithRoute(r ContextRequestRoute) ContextBuilder
WithRoute sets the ContextRequestRoute in the context. This should be set to identify the logical route or endpoint of the request within the target system.
func (ContextBuilder) WithSource ¶
func (cb ContextBuilder) WithSource(s string) ContextBuilder
WithSource sets the ContextSource in the context. This should be set where the context originates. If the context originates internally, use ContextSourceInternal.
func (ContextBuilder) WithTarget ¶
func (cb ContextBuilder) WithTarget(t ContextRequestTarget) ContextBuilder
WithTarget sets the ContextRequestTarget in the context. This should be set to identify the target of the request, typically in frontend and API Layers. Frontends should almost always set this to the orchestrator name, while outgoing APIs should set this to the target system name or address.
func (ContextBuilder) WithWorkflow ¶
func (cb ContextBuilder) WithWorkflow(w Workflow) ContextBuilder
WithWorkflow sets the Workflow in the context.
type ContextKey ¶
type ContextKey string // ContextKeyRequestID is the ContextKey for RequestID
ContextKey is used for context.Context value. The value requires a key that is not primitive type.
const ( ContextKeyWorkflow ContextKey = "workflow" ContextKeyLogLayer ContextKey = "logLayer" ContextKeyRequestID ContextKey = "requestID" ContextKeyRequestSource ContextKey = "requestSource" ContextKeyRequestClient ContextKey = "requestClient" ContextKeyRequestTarget ContextKey = "requestTarget" ContextKeyRequestAddress ContextKey = "requestAddress" ContextKeyRequestRoute ContextKey = "requestRoute" ContextKeyRequestMethod ContextKey = "requestMethod" CRDControllerEvent ContextKey = "crdControllerEvent" )
Context Keys are top-level keys for context.Context values used in Trident logging and context-based telemetry. These keys should be unique and not primitive types to avoid collisions. When adding new ContextKey constants, ensure they are added to the contextKeys list.
type ContextRequestAddress ¶
type ContextRequestAddress = string
ContextRequestAddress models the target of a request in the context.
type ContextRequestClient ¶
type ContextRequestClient = string
ContextRequestClient models the client of a request in the context.
const ( ContextRequestClientUnknown ContextRequestClient = "unknown" ContextRequestClientCSIAny ContextRequestClient = "csi-any" ContextRequestClientCSIProvisioner ContextRequestClient = "csi-provisioner" ContextRequestClientCSIResizer ContextRequestClient = "csi-resizer" ContextRequestClientCSISnapshotter ContextRequestClient = "csi-snapshotter" ContextRequestClientCSIAttacher ContextRequestClient = "csi-attacher" ContextRequestClientTridentCLI ContextRequestClient = "trident-cli" ContextRequestClientCSINodeClient ContextRequestClient = "csi-node-client" ContextRequestClientCSINodeDriverRegistrar ContextRequestClient = "csi-node-registrar" ContextRequestClientTridentNode ContextRequestClient = "trident-node" )
Context Request Client Values are stock values that should be used with incoming and outgoing requests to identify the client system or component in Trident. Custom client values can also be used based on the client system or component.
type ContextRequestMethod ¶
type ContextRequestMethod = string
ContextRequestMethod models the method of a request in the context.
type ContextRequestRoute ¶
type ContextRequestRoute = string
ContextRequestRoute models the route of a request in the context.
type ContextRequestTarget ¶
type ContextRequestTarget = string
ContextRequestTarget models the target of a request in the context.
const ( ContextRequestTargetUnknown ContextRequestTarget = "unknown" ContextRequestTargetTrident ContextRequestTarget = "trident" ContextRequestTargetKubernetes ContextRequestTarget = "kubernetes" ContextRequestTargetONTAP ContextRequestTarget = "ontap" ContextRequestTargetGCNV ContextRequestTarget = "gcnv" )
Context Request Target Values are stock values that should be used with incoming and outgoing requests in Trident. Custom target values can also be used based on the target system or component.
type ContextSource ¶
type ContextSource = string
ContextSource models the source system or component of a request in the context.
type FileHook ¶
type FileHook struct {
// contains filtered or unexported fields
}
FileHook sends log entries to a file.
func NewFileHook ¶
NewFileHook creates a new log hook for writing to a file.
func (*FileHook) GetLocation ¶
type JSONFormatter ¶
type LogEntry ¶
type LogEntry interface {
WithField(key string, value interface{}) LogEntry
WithFields(fields LogFields) LogEntry
WithError(err error) LogEntry
Fatal(args ...interface{})
Fatalf(format string, args ...interface{})
Error(args ...interface{})
Errorf(format string, args ...interface{})
Warn(args ...interface{})
Warnf(format string, args ...interface{})
Warning(args ...interface{})
Warningf(format string, args ...interface{})
Info(args ...interface{})
Infof(format string, args ...interface{})
Debug(args ...interface{})
Debugf(format string, args ...interface{})
Trace(args ...interface{})
Tracef(format string, args ...interface{})
Data(key string) (interface{}, bool)
}
func Log ¶
func Log() LogEntry
Log is a convenience function for calling Logc with a background context in places where the context is not important.
type MetricsTransport ¶
type MetricsTransport struct {
// contains filtered or unexported fields
}
MetricsTransport is an HTTP transport that records metrics for outgoing HTTP requests via RoundTripper.
type MetricsTransportOption ¶
type MetricsTransportOption func(*MetricsTransport)
func WithMetricsTransportTarget ¶
func WithMetricsTransportTarget(target ContextRequestTarget) MetricsTransportOption
type PlainTextFormatter ¶
type PlainTextFormatter struct {
// TimestampFormat to use for display when a full timestamp is printed
TimestampFormat string
// The fields are sorted by default for a consistent output. For applications
// that log extremely frequently and don't use the JSON formatter this may not
// be desired.
DisableSorting bool
}
PlainTextFormatter is a formatter than does no coloring *and* does not insist on writing logs as key/value pairs.
type Recorder ¶
type Recorder func(err *error)
Recorder records metrics by relying on a captured context and errors that have been staged by the Telemeter.
type Telemeter ¶
Telemeter stages metrics recording by capturing the current state of a context and returns a Recorder.
func IncomingAPITelemeter ¶
IncomingAPITelemeter starts tracking an incoming request. It captures all incoming API metrics: in-flight count and request duration. client and method are required — they are Prometheus label fields. ctx is used only for lifecycle signals (cancellation, deadline).
func OutgoingAPITelemeter ¶
OutgoingAPITelemeter starts tracking an outgoing request. It captures outgoing API metrics: in-flight count, request duration, and backpressure.
type Workflow ¶
type Workflow struct {
Category WorkflowCategory
Operation WorkflowOperation
}
type WorkflowCategory ¶
type WorkflowCategory string
func (WorkflowCategory) String ¶
func (w WorkflowCategory) String() string
type WorkflowOperation ¶
type WorkflowOperation string
func (WorkflowOperation) String ¶
func (w WorkflowOperation) String() string