mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 02:43:36 +00:00
build: move e2e dependencies into e2e/go.mod
Several packages are only used while running the e2e suite. These packages are less important to update, as the they can not influence the final executable that is part of the Ceph-CSI container-image. By moving these dependencies out of the main Ceph-CSI go.mod, it is easier to identify if a reported CVE affects Ceph-CSI, or only the testing (like most of the Kubernetes CVEs). Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
committed by
mergify[bot]
parent
15da101b1b
commit
bec6090996
67
e2e/vendor/k8s.io/utils/trace/README.md
generated
vendored
Normal file
67
e2e/vendor/k8s.io/utils/trace/README.md
generated
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
# Trace
|
||||
|
||||
This package provides an interface for recording the latency of operations and logging details
|
||||
about all operations where the latency exceeds a limit.
|
||||
|
||||
## Usage
|
||||
|
||||
To create a trace:
|
||||
|
||||
```go
|
||||
func doSomething() {
|
||||
opTrace := trace.New("operation", Field{Key: "fieldKey1", Value: "fieldValue1"})
|
||||
defer opTrace.LogIfLong(100 * time.Millisecond)
|
||||
// do something
|
||||
}
|
||||
```
|
||||
|
||||
To split an trace into multiple steps:
|
||||
|
||||
```go
|
||||
func doSomething() {
|
||||
opTrace := trace.New("operation")
|
||||
defer opTrace.LogIfLong(100 * time.Millisecond)
|
||||
// do step 1
|
||||
opTrace.Step("step1", Field{Key: "stepFieldKey1", Value: "stepFieldValue1"})
|
||||
// do step 2
|
||||
opTrace.Step("step2")
|
||||
}
|
||||
```
|
||||
|
||||
To nest traces:
|
||||
|
||||
```go
|
||||
func doSomething() {
|
||||
rootTrace := trace.New("rootOperation")
|
||||
defer rootTrace.LogIfLong(100 * time.Millisecond)
|
||||
|
||||
func() {
|
||||
nestedTrace := rootTrace.Nest("nested", Field{Key: "nestedFieldKey1", Value: "nestedFieldValue1"})
|
||||
defer nestedTrace.LogIfLong(50 * time.Millisecond)
|
||||
// do nested operation
|
||||
}()
|
||||
}
|
||||
```
|
||||
|
||||
Traces can also be logged unconditionally or introspected:
|
||||
|
||||
```go
|
||||
opTrace.TotalTime() // Duration since the Trace was created
|
||||
opTrace.Log() // unconditionally log the trace
|
||||
```
|
||||
|
||||
### Using context.Context to nest traces
|
||||
|
||||
`context.Context` can be used to manage nested traces. Create traces by calling `trace.GetTraceFromContext(ctx).Nest`.
|
||||
This is safe even if there is no parent trace already in the context because `(*(Trace)nil).Nest()` returns
|
||||
a top level trace.
|
||||
|
||||
```go
|
||||
func doSomething(ctx context.Context) {
|
||||
opTrace := trace.FromContext(ctx).Nest("operation") // create a trace, possibly nested
|
||||
ctx = trace.ContextWithTrace(ctx, opTrace) // make this trace the parent trace of the context
|
||||
defer opTrace.LogIfLong(50 * time.Millisecond)
|
||||
|
||||
doSomethingElse(ctx)
|
||||
}
|
||||
```
|
Reference in New Issue
Block a user