Skip to content

Commit c01bb9d

Browse files
committed
probers: initiate traces for browser, scripted, and multihttp checks
1 parent 411eb89 commit c01bb9d

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

internal/prober/browser/browser.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ import (
66

77
"github.com/grafana/synthetic-monitoring-agent/internal/k6runner"
88
"github.com/grafana/synthetic-monitoring-agent/internal/prober/logger"
9+
"github.com/grafana/synthetic-monitoring-agent/internal/tracing"
910
sm "github.com/grafana/synthetic-monitoring-agent/pkg/pb/synthetic_monitoring"
1011
"github.com/prometheus/client_golang/prometheus"
1112
"github.com/rs/zerolog"
13+
"go.opentelemetry.io/otel/attribute"
1214
)
1315

1416
const proberName = "browser"
@@ -60,12 +62,18 @@ func (p Prober) Name() string {
6062
}
6163

6264
func (p Prober) Probe(ctx context.Context, target string, registry *prometheus.Registry, logger logger.Logger) (bool, float64) {
65+
ctx, probeSpan := tracing.TracerProvider(ctx).Tracer("").Start(ctx, "browser check")
66+
defer probeSpan.End()
67+
6368
success, err := p.processor.Run(ctx, registry, logger, p.logger)
6469
if err != nil {
6570
p.logger.Error().Err(err).Msg("running probe")
71+
probeSpan.RecordError(err)
6672
return false, 0
6773
}
6874

75+
probeSpan.SetAttributes(attribute.Bool("success", success))
76+
6977
// TODO(mem): implement custom duration extraction.
7078
return success, 0
7179
}

internal/prober/multihttp/multihttp.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ import (
88

99
"github.com/grafana/synthetic-monitoring-agent/internal/k6runner"
1010
"github.com/grafana/synthetic-monitoring-agent/internal/prober/logger"
11+
"github.com/grafana/synthetic-monitoring-agent/internal/tracing"
1112
sm "github.com/grafana/synthetic-monitoring-agent/pkg/pb/synthetic_monitoring"
1213
"github.com/prometheus/client_golang/prometheus"
1314
"github.com/rs/zerolog"
15+
"go.opentelemetry.io/otel/attribute"
1416
)
1517

1618
const proberName = "multihttp"
@@ -83,12 +85,18 @@ func (p Prober) Name() string {
8385
}
8486

8587
func (p Prober) Probe(ctx context.Context, target string, registry *prometheus.Registry, logger logger.Logger) (bool, float64) {
88+
ctx, probeSpan := tracing.TracerProvider(ctx).Tracer("").Start(ctx, "multihttp check")
89+
defer probeSpan.End()
90+
8691
success, err := p.processor.Run(ctx, registry, logger, p.logger)
8792
if err != nil {
8893
p.logger.Error().Err(err).Msg("running probe")
94+
probeSpan.RecordError(err)
8995
return false, 0
9096
}
9197

98+
probeSpan.SetAttributes(attribute.Bool("success", success))
99+
92100
// TODO(mem): implement custom duration extraction.
93101
return success, 0
94102
}

internal/prober/scripted/scripted.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ import (
66

77
"github.com/grafana/synthetic-monitoring-agent/internal/k6runner"
88
"github.com/grafana/synthetic-monitoring-agent/internal/prober/logger"
9+
"github.com/grafana/synthetic-monitoring-agent/internal/tracing"
910
sm "github.com/grafana/synthetic-monitoring-agent/pkg/pb/synthetic_monitoring"
1011
"github.com/prometheus/client_golang/prometheus"
1112
"github.com/rs/zerolog"
13+
"go.opentelemetry.io/otel/attribute"
1214
)
1315

1416
const proberName = "scripted"
@@ -60,12 +62,17 @@ func (p Prober) Name() string {
6062
}
6163

6264
func (p Prober) Probe(ctx context.Context, target string, registry *prometheus.Registry, logger logger.Logger) (bool, float64) {
65+
ctx, probeSpan := tracing.TracerProvider(ctx).Tracer("").Start(ctx, "scripted check")
66+
defer probeSpan.End()
67+
6368
success, err := p.processor.Run(ctx, registry, logger, p.logger)
6469
if err != nil {
6570
p.logger.Error().Err(err).Msg("running probe")
71+
probeSpan.RecordError(err)
6672
return false, 0
6773
}
6874

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

0 commit comments

Comments
 (0)