diff --git a/internal/prober/browser/browser.go b/internal/prober/browser/browser.go index bff751eae..152dec4e9 100644 --- a/internal/prober/browser/browser.go +++ b/internal/prober/browser/browser.go @@ -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" @@ -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 } diff --git a/internal/prober/multihttp/multihttp.go b/internal/prober/multihttp/multihttp.go index 93970f7e0..77c168c45 100644 --- a/internal/prober/multihttp/multihttp.go +++ b/internal/prober/multihttp/multihttp.go @@ -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" @@ -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 } diff --git a/internal/prober/scripted/scripted.go b/internal/prober/scripted/scripted.go index da50456ea..535a6fd54 100644 --- a/internal/prober/scripted/scripted.go +++ b/internal/prober/scripted/scripted.go @@ -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" @@ -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 }