Skip to content

Commit dc7ad55

Browse files
committed
telemetry: start trace on last commit timestamp; cleanups
1 parent 0388e3f commit dc7ad55

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

pkg/deployclient/deployer.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ func Prepare(ctx context.Context, cfg *Config) (*pb.DeploymentRequest, error) {
4444
var err error
4545
templateVariables := make(TemplateVariables)
4646

47-
ctx, span := telemetry.Tracer().Start(ctx, "Templating and validation")
48-
defer span.End()
49-
5047
err = cfg.Validate()
5148
if err != nil {
5249
if !errors.Is(err, ErrInvalidTelemetryFormat) {
@@ -164,12 +161,11 @@ func (d *Deployer) Deploy(ctx context.Context, cfg *Config, deployRequest *pb.De
164161

165162
// Root span for tracing.
166163
// All sub-spans must be created from this context.
167-
ctx, rootSpan := cfg.Telemetry.StartTracing(ctx, "Continuous integration pipeline")
164+
ctx, rootSpan := cfg.Telemetry.StartTracing(ctx)
168165
defer rootSpan.End()
169166
deployRequest.TraceParent = telemetry.TraceParentHeader(ctx)
170167

171168
log.Infof("Sending deployment request to NAIS deploy at %s...", cfg.DeployServerURL)
172-
log.Infof("Trace parent for this request: %s", deployRequest.TraceParent)
173169

174170
sendDeploymentRequest := func() error {
175171
ctx, span := telemetry.Tracer().Start(ctx, "Send to deploy server")

pkg/grpc/dispatchserver/broker.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func (s *dispatchServer) SendDeploymentRequest(ctx context.Context, request *pb.
2727

2828
ctx = telemetry.WithTraceParent(ctx, request.TraceParent)
2929
s.traceSpansLock.Lock()
30-
ctx, span := telemetry.Tracer().Start(ctx, "Dispatch to cluster", otrace.WithSpanKind(otrace.SpanKindServer))
30+
ctx, span := telemetry.Tracer().Start(ctx, "Deploy", otrace.WithSpanKind(otrace.SpanKindServer))
3131
s.traceSpans[request.ID] = span
3232
request.TraceParent = telemetry.TraceParentHeader(ctx)
3333
s.traceSpansLock.Unlock()

pkg/telemetry/telemetry.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,13 @@ func (pt *PipelineTimings) Validate() error {
146146
return nil
147147
}
148148

149-
func (pt *PipelineTimings) StartTracing(ctx context.Context, name string) (context.Context, otrace.Span) {
149+
func (pt *PipelineTimings) StartTracing(ctx context.Context) (context.Context, otrace.Span) {
150150
if pt == nil {
151-
return Tracer().Start(ctx, name, otrace.WithSpanKind(otrace.SpanKindServer))
151+
return Tracer().Start(ctx, "Continuous integration pipeline", otrace.WithSpanKind(otrace.SpanKindServer))
152152
}
153153

154-
rootCtx, rootSpan := Tracer().Start(ctx, name, otrace.WithTimestamp(pt.Start), otrace.WithSpanKind(otrace.SpanKindServer))
154+
rootCtx, rootSpan := Tracer().Start(ctx, "Continuous integration pipeline", otrace.WithTimestamp(pt.LatestCommit), otrace.WithSpanKind(otrace.SpanKindServer))
155+
rootSpan.AddEvent("Latest commit to repository", otrace.WithTimestamp(pt.LatestCommit))
155156
{
156157
ciCtx, ciSpan := Tracer().Start(rootCtx, "Github Action: docker-build-push", otrace.WithTimestamp(pt.Start), otrace.WithAttributes())
157158
{

0 commit comments

Comments
 (0)