AsProfiled wraps e2e.Runnable with ProfiledRunnable. If runnable is running during invocation AsProfiled panics. NOTE(bwplotka): Caller is expected to discard passed `r` runnable and use returned ProfiledRunnable.Runnable instead.
(r e2e.Runnable, pprofPortName string, opts ...ProfiledOption)
| 55 | // If runnable is running during invocation AsProfiled panics. |
| 56 | // NOTE(bwplotka): Caller is expected to discard passed `r` runnable and use returned ProfiledRunnable.Runnable instead. |
| 57 | func AsProfiled(r e2e.Runnable, pprofPortName string, opts ...ProfiledOption) *ProfiledRunnable { |
| 58 | if r.IsRunning() { |
| 59 | panic("can't use AsProfiled with running runnable") |
| 60 | } |
| 61 | |
| 62 | opt := rOpt{ |
| 63 | scheme: "http", |
| 64 | } |
| 65 | for _, o := range opts { |
| 66 | o(&opt) |
| 67 | } |
| 68 | |
| 69 | if r.InternalEndpoint(pprofPortName) == "" { |
| 70 | return &ProfiledRunnable{Runnable: e2e.NewFailedRunnable(r.Name(), errors.Newf("pprof port name %v does not exist in given runnable ports", pprofPortName))} |
| 71 | } |
| 72 | |
| 73 | instr := &ProfiledRunnable{ |
| 74 | Runnable: r, |
| 75 | pprofPort: pprofPortName, |
| 76 | scheme: opt.scheme, |
| 77 | config: opt.config, |
| 78 | } |
| 79 | r.SetMetadata(metaKey, Profiled(instr)) |
| 80 | return instr |
| 81 | } |
| 82 | |
| 83 | func (r *ProfiledRunnable) ProfileTargets() []Target { |
| 84 | return []Target{{Name: r.Name(), Scheme: r.scheme, Config: r.config, InternalEndpoint: r.InternalEndpoint(r.pprofPort)}} |
nothing calls this directly
no test coverage detected
searching dependent graphs…