trace: Support overriding step duration using a field
- Dominant language
- Go
- Stars
- 380
- Forks
- 224
- PR merge metrics
- No merged PRs in 30d
Description
**Is your feature request related to a problem?/Why is this needed**
While implementing aggregated trace events for streaming in https://github.com/kubernetes/kubernetes/pull/138873, we found it would be helpful to be able to explicitly pass the duration to the trace library: https://github.com/kubernetes/kubernetes/pull/138873#issuecomment-4401792682
**Describe the solution you'd like in detail**
When the `duration` key is provided to trace.Step(), omit it from the printed fields, and instead use its value for the step duration.
Instead of:
```
Trace[195300817]: ---"Compress" size:131088,count:1,duration:3.5321ms,parallel:true 0ms (20:36:57.082)]
```
After
```
Trace[195300817]: ---"Compress" size:131088,count:1,parallel:true 3.5321ms (20:36:57.082)]
```
**Describe alternatives you've considered**
* Just leave it as-is. The 0ms might be confusing for readers.
* Support explicitly passing the duration as a parameter to Step() (probably using a new function)
@serathius @richabanker
Contributor guide
Research direction
Start by locating the trace.Step() entry point and the code that formats step fields and duration. Verify how the duration field is currently printed and how step timing is calculated. Done means a provided duration controls the displayed step duration and is omitted from the printed fields, while other fields remain unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- observability
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100