Skip to content

Commit

Permalink
probers: initiate traces for browser, scripted, and multihttp checks
Browse files Browse the repository at this point in the history
  • Loading branch information
roobre committed Oct 4, 2024
1 parent 411eb89 commit c01bb9d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/prober/browser/browser.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import (

"github.com/grafana/synthetic-monitoring-agent/internal/k6runner"
"github.com/grafana/synthetic-monitoring-agent/internal/prober/logger"
"github.com/grafana/synthetic-monitoring-agent/internal/tracing"
sm "github.com/grafana/synthetic-monitoring-agent/pkg/pb/synthetic_monitoring"
"github.com/prometheus/client_golang/prometheus"
"github.com/rs/zerolog"
"go.opentelemetry.io/otel/attribute"
)

const proberName = "browser"
Expand Down Expand Up @@ -60,12 +62,18 @@ func (p Prober) Name() string {
}

func (p Prober) Probe(ctx context.Context, target string, registry *prometheus.Registry, logger logger.Logger) (bool, float64) {
ctx, probeSpan := tracing.TracerProvider(ctx).Tracer("").Start(ctx, "browser check")
defer probeSpan.End()

success, err := p.processor.Run(ctx, registry, logger, p.logger)
if err != nil {
p.logger.Error().Err(err).Msg("running probe")
probeSpan.RecordError(err)
return false, 0
}

probeSpan.SetAttributes(attribute.Bool("success", success))

// TODO(mem): implement custom duration extraction.
return success, 0
}
8 changes: 8 additions & 0 deletions internal/prober/multihttp/multihttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import (

"github.com/grafana/synthetic-monitoring-agent/internal/k6runner"
"github.com/grafana/synthetic-monitoring-agent/internal/prober/logger"
"github.com/grafana/synthetic-monitoring-agent/internal/tracing"
sm "github.com/grafana/synthetic-monitoring-agent/pkg/pb/synthetic_monitoring"
"github.com/prometheus/client_golang/prometheus"
"github.com/rs/zerolog"
"go.opentelemetry.io/otel/attribute"
)

const proberName = "multihttp"
Expand Down Expand Up @@ -83,12 +85,18 @@ func (p Prober) Name() string {
}

func (p Prober) Probe(ctx context.Context, target string, registry *prometheus.Registry, logger logger.Logger) (bool, float64) {
ctx, probeSpan := tracing.TracerProvider(ctx).Tracer("").Start(ctx, "multihttp check")
defer probeSpan.End()

success, err := p.processor.Run(ctx, registry, logger, p.logger)
if err != nil {
p.logger.Error().Err(err).Msg("running probe")
probeSpan.RecordError(err)
return false, 0
}

probeSpan.SetAttributes(attribute.Bool("success", success))

// TODO(mem): implement custom duration extraction.
return success, 0
}
Expand Down
7 changes: 7 additions & 0 deletions internal/prober/scripted/scripted.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import (

"github.com/grafana/synthetic-monitoring-agent/internal/k6runner"
"github.com/grafana/synthetic-monitoring-agent/internal/prober/logger"
"github.com/grafana/synthetic-monitoring-agent/internal/tracing"
sm "github.com/grafana/synthetic-monitoring-agent/pkg/pb/synthetic_monitoring"
"github.com/prometheus/client_golang/prometheus"
"github.com/rs/zerolog"
"go.opentelemetry.io/otel/attribute"
)

const proberName = "scripted"
Expand Down Expand Up @@ -60,12 +62,17 @@ func (p Prober) Name() string {
}

func (p Prober) Probe(ctx context.Context, target string, registry *prometheus.Registry, logger logger.Logger) (bool, float64) {
ctx, probeSpan := tracing.TracerProvider(ctx).Tracer("").Start(ctx, "scripted check")
defer probeSpan.End()

success, err := p.processor.Run(ctx, registry, logger, p.logger)
if err != nil {
p.logger.Error().Err(err).Msg("running probe")
probeSpan.RecordError(err)
return false, 0
}

probeSpan.SetAttributes(attribute.Bool("success", success))
// TODO(mem): implement custom duration extraction.
return success, 0
}

0 comments on commit c01bb9d

Please sign in to comment.