Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor traces attributes #1140

Merged
merged 1 commit into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions browser/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,9 @@ func (r *tracesRegistry) startIterationTrace(ctx context.Context, data k6event.I
}

spanCtx, span := r.tracer.Start(ctx, "iteration", oteltrace.WithAttributes(
attribute.Int64("number", data.Iteration),
attribute.Int64("vu", int64(data.VUID)),
attribute.String("scenario", data.ScenarioName),
attribute.Int64("test.iteration.number", data.Iteration),
attribute.Int64("test.vu", int64(data.VUID)),
attribute.String("test.scenario", data.ScenarioName),
))

r.m[data.Iteration] = &trace{
Expand Down
2 changes: 1 addition & 1 deletion common/element_handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,7 @@ func (h *ElementHandle) Screenshot(opts goja.Value) goja.ArrayBuffer {
if err := parsedOpts.Parse(h.ctx, opts); err != nil {
k6ext.Panic(h.ctx, "parsing screenshot options: %w", err)
}
span.SetAttributes(attribute.String("path", parsedOpts.Path))
span.SetAttributes(attribute.String("screenshot.path", parsedOpts.Path))

s := newScreenshotter(spanCtx)
buf, err := s.screenshotElement(h, parsedOpts)
Expand Down
9 changes: 6 additions & 3 deletions common/frame_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,11 @@ func (fs *FrameSession) parseAndEmitWebVitalMetric(object string) error {
})

_, span := TraceEvent(
fs.ctx, fs.targetID.String(), "web_vital", wv.SpanID,
trace.WithAttributes(attribute.Float64(wv.Name, value), attribute.String("rating", wv.Rating)))
fs.ctx, fs.targetID.String(), "web_vital", wv.SpanID, trace.WithAttributes(
attribute.String("web_vital.name", wv.Name),
ka3de marked this conversation as resolved.
Show resolved Hide resolved
attribute.Float64("web_vital.value", value),
attribute.String("web_vital.rating", wv.Rating),
))
defer span.End()

return nil
Expand Down Expand Up @@ -754,7 +757,7 @@ func (fs *FrameSession) onFrameNavigated(frame *cdp.Frame, initial bool) {

_, fs.mainFrameSpan = TraceNavigation(
fs.ctx, fs.targetID.String(), frame.URL,
trace.WithAttributes(attribute.String("url", frame.URL)),
trace.WithAttributes(attribute.String("navigation.url", frame.URL)),
)

var (
Expand Down
4 changes: 2 additions & 2 deletions common/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ func (p *Page) Goto(url string, opts goja.Value) (*Response, error) {
p.ctx,
p.targetID.String(),
"page.goto",
trace.WithAttributes(attribute.String("url", url)),
trace.WithAttributes(attribute.String("page.goto.url", url)),
)
defer span.End()

Expand Down Expand Up @@ -1113,7 +1113,7 @@ func (p *Page) Screenshot(opts goja.Value) goja.ArrayBuffer {
if err := parsedOpts.Parse(p.ctx, opts); err != nil {
k6ext.Panic(p.ctx, "parsing screenshot options: %w", err)
}
span.SetAttributes(attribute.String("path", parsedOpts.Path))
span.SetAttributes(attribute.String("screenshot.path", parsedOpts.Path))

s := newScreenshotter(spanCtx)
buf, err := s.screenshotPage(p, parsedOpts)
Expand Down
2 changes: 1 addition & 1 deletion trace/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
k6lib "go.k6.io/k6/lib"
)

const tracerName = "browser"
const tracerName = "k6.browser"
ka3de marked this conversation as resolved.
Show resolved Hide resolved

// liveSpan represents an active span associated with a page navigation.
//
Expand Down
Loading