From 344f2f2bbb4ddd6c4f1ad140256e7e4c58b29923 Mon Sep 17 00:00:00 2001 From: ankur22 Date: Fri, 5 Apr 2024 15:14:20 +0100 Subject: [PATCH] Add reload errors to span --- common/page.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/common/page.go b/common/page.go index 09950cadf..585b919f1 100644 --- a/common/page.go +++ b/common/page.go @@ -1054,7 +1054,9 @@ func (p *Page) Reload(opts goja.Value) (*Response, error) { //nolint:funlen,cycl p.timeoutSettings.navigationTimeout(), ) if err := parsedOpts.Parse(p.ctx, opts); err != nil { - return nil, fmt.Errorf("parsing reload options: %w", err) + err = fmt.Errorf("parsing reload options: %w", err) + SpanRecordError(span, "reload option parsing failed", err) + return nil, err } timeoutCtx, timeoutCancelFn := context.WithTimeout(p.ctx, parsedOpts.Timeout) @@ -1080,7 +1082,9 @@ func (p *Page) Reload(opts goja.Value) (*Response, error) { //nolint:funlen,cycl action := cdppage.Reload() if err := action.Do(cdp.WithExecutor(p.ctx, p.session)); err != nil { - return nil, fmt.Errorf("reloading page: %w", err) + err = fmt.Errorf("reloading page: %w", err) + SpanRecordError(span, "reload failed", err) + return nil, err } wrapTimeoutError := func(err error) error { @@ -1100,7 +1104,9 @@ func (p *Page) Reload(opts goja.Value) (*Response, error) { //nolint:funlen,cycl select { case <-p.ctx.Done(): case <-timeoutCtx.Done(): - return nil, wrapTimeoutError(timeoutCtx.Err()) + err := wrapTimeoutError(timeoutCtx.Err()) + SpanRecordError(span, "reload navigation timed out", err) + return nil, err case data := <-ch: event = data.(*NavigationEvent) } @@ -1116,7 +1122,9 @@ func (p *Page) Reload(opts goja.Value) (*Response, error) { //nolint:funlen,cycl select { case <-lifecycleEvtCh: case <-timeoutCtx.Done(): - return nil, wrapTimeoutError(timeoutCtx.Err()) + err := wrapTimeoutError(timeoutCtx.Err()) + SpanRecordError(span, "reload lifecycle timed out", err) + return nil, err } applySlowMo(p.ctx)