Skip to content

Commit fed2fe0

Browse files
APM: tracer setup with Disruption and Reconcile spans (#721)
1 parent 8057e50 commit fed2fe0

File tree

270 files changed

+46697
-32
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

270 files changed

+46697
-32
lines changed

LICENSE-3rdparty.csv

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ github.com/AlecAivazis/survey/v2,github.com/AlecAivazis/survey/v2/core,MIT
44
github.com/AlecAivazis/survey/v2,github.com/AlecAivazis/survey/v2/terminal,MIT
55
github.com/DataDog/appsec-internal-go,github.com/DataDog/appsec-internal-go/httpsec,Apache-2.0
66
github.com/DataDog/appsec-internal-go,github.com/DataDog/appsec-internal-go/netip,Apache-2.0
7+
github.com/DataDog/datadog-agent/pkg/obfuscate,github.com/DataDog/datadog-agent/pkg/obfuscate,Apache-2.0
78
github.com/DataDog/datadog-agent/pkg/remoteconfig/state,github.com/DataDog/datadog-agent/pkg/remoteconfig/state,Apache-2.0
89
github.com/DataDog/datadog-go,github.com/DataDog/datadog-go/statsd,MIT
910
github.com/DataDog/datadog-go/v5,github.com/DataDog/datadog-go/v5/statsd,MIT
@@ -22,6 +23,12 @@ github.com/DataDog/go-tuf,github.com/DataDog/go-tuf/pkg/targets,BSD-3-Clause
2223
github.com/DataDog/go-tuf,github.com/DataDog/go-tuf/util,BSD-3-Clause
2324
github.com/DataDog/go-tuf,github.com/DataDog/go-tuf/verify,BSD-3-Clause
2425
github.com/DataDog/gostackparse,github.com/DataDog/gostackparse,Apache-2.0
26+
github.com/DataDog/sketches-go,github.com/DataDog/sketches-go/ddsketch,Apache-2.0
27+
github.com/DataDog/sketches-go,github.com/DataDog/sketches-go/ddsketch/encoding,Apache-2.0
28+
github.com/DataDog/sketches-go,github.com/DataDog/sketches-go/ddsketch/mapping,Apache-2.0
29+
github.com/DataDog/sketches-go,github.com/DataDog/sketches-go/ddsketch/pb/sketchpb,Apache-2.0
30+
github.com/DataDog/sketches-go,github.com/DataDog/sketches-go/ddsketch/stat,Apache-2.0
31+
github.com/DataDog/sketches-go,github.com/DataDog/sketches-go/ddsketch/store,Apache-2.0
2532
github.com/Microsoft/go-winio,github.com/Microsoft/go-winio,MIT
2633
github.com/Microsoft/go-winio,github.com/Microsoft/go-winio/backuptar,MIT
2734
github.com/Microsoft/go-winio,github.com/Microsoft/go-winio/internal/fs,MIT
@@ -157,13 +164,15 @@ github.com/docker/go-connections,github.com/docker/go-connections/sockets,Apache
157164
github.com/docker/go-connections,github.com/docker/go-connections/tlsconfig,Apache-2.0
158165
github.com/docker/go-events,github.com/docker/go-events,Apache-2.0
159166
github.com/docker/go-units,github.com/docker/go-units,Apache-2.0
167+
github.com/dustin/go-humanize,github.com/dustin/go-humanize,MIT
160168
github.com/emicklei/go-restful/v3,github.com/emicklei/go-restful/v3,MIT
161169
github.com/emicklei/go-restful/v3,github.com/emicklei/go-restful/v3/log,MIT
162170
github.com/evanphx/json-patch,github.com/evanphx/json-patch,BSD-3-Clause
163171
github.com/evanphx/json-patch/v5,github.com/evanphx/json-patch/v5,BSD-3-Clause
164172
github.com/fsnotify/fsnotify,github.com/fsnotify/fsnotify,BSD-3-Clause
165173
github.com/go-logr/logr,github.com/go-logr/logr,Apache-2.0
166174
github.com/go-logr/logr,github.com/go-logr/logr/funcr,Apache-2.0
175+
github.com/go-logr/stdr,github.com/go-logr/stdr,Apache-2.0
167176
github.com/go-openapi/jsonpointer,github.com/go-openapi/jsonpointer,Apache-2.0
168177
github.com/go-openapi/jsonreference,github.com/go-openapi/jsonreference,Apache-2.0
169178
github.com/go-openapi/jsonreference,github.com/go-openapi/jsonreference/internal,Apache-2.0
@@ -291,11 +300,15 @@ github.com/opencontainers/runtime-spec,github.com/opencontainers/runtime-spec/sp
291300
github.com/opencontainers/selinux,github.com/opencontainers/selinux/go-selinux,Apache-2.0
292301
github.com/opencontainers/selinux,github.com/opencontainers/selinux/go-selinux/label,Apache-2.0
293302
github.com/opencontainers/selinux,github.com/opencontainers/selinux/pkg/pwalkdir,Apache-2.0
303+
github.com/outcaste-io/ristretto,github.com/outcaste-io/ristretto,Apache-2.0
304+
github.com/outcaste-io/ristretto,github.com/outcaste-io/ristretto/z,Apache-2.0
305+
github.com/outcaste-io/ristretto,github.com/outcaste-io/ristretto/z/simd,Apache-2.0
294306
github.com/pelletier/go-toml/v2,github.com/pelletier/go-toml/v2,MIT
295307
github.com/pelletier/go-toml/v2,github.com/pelletier/go-toml/v2/internal/characters,MIT
296308
github.com/pelletier/go-toml/v2,github.com/pelletier/go-toml/v2/internal/danger,MIT
297309
github.com/pelletier/go-toml/v2,github.com/pelletier/go-toml/v2/internal/tracker,MIT
298310
github.com/pelletier/go-toml/v2,github.com/pelletier/go-toml/v2/unstable,MIT
311+
github.com/philhofer/fwd,github.com/philhofer/fwd,MIT
299312
github.com/pkg/errors,github.com/pkg/errors,BSD-2-Clause
300313
github.com/pmezard/go-difflib,github.com/pmezard/go-difflib/difflib,BSD-3-Clause
301314
github.com/prometheus/client_golang,github.com/prometheus/client_golang/prometheus,Apache-2.0
@@ -341,6 +354,7 @@ github.com/stretchr/testify,github.com/stretchr/testify/assert,MIT
341354
github.com/stretchr/testify,github.com/stretchr/testify/mock,MIT
342355
github.com/stretchr/testify,github.com/stretchr/testify/require,MIT
343356
github.com/subosito/gotenv,github.com/subosito/gotenv,MIT
357+
github.com/tinylib/msgp,github.com/tinylib/msgp/msgp,MIT
344358
github.com/vishvananda/netlink,github.com/vishvananda/netlink,Apache-2.0
345359
github.com/vishvananda/netlink,github.com/vishvananda/netlink/nl,Apache-2.0
346360
github.com/vishvananda/netns,github.com/vishvananda/netns,Apache-2.0
@@ -349,6 +363,18 @@ go.opencensus.io,go.opencensus.io/internal,Apache-2.0
349363
go.opencensus.io,go.opencensus.io/trace,Apache-2.0
350364
go.opencensus.io,go.opencensus.io/trace/internal,Apache-2.0
351365
go.opencensus.io,go.opencensus.io/trace/tracestate,Apache-2.0
366+
go.opentelemetry.io/otel,go.opentelemetry.io/otel,Apache-2.0
367+
go.opentelemetry.io/otel,go.opentelemetry.io/otel/attribute,Apache-2.0
368+
go.opentelemetry.io/otel,go.opentelemetry.io/otel/baggage,Apache-2.0
369+
go.opentelemetry.io/otel,go.opentelemetry.io/otel/codes,Apache-2.0
370+
go.opentelemetry.io/otel,go.opentelemetry.io/otel/internal,Apache-2.0
371+
go.opentelemetry.io/otel,go.opentelemetry.io/otel/internal/attribute,Apache-2.0
372+
go.opentelemetry.io/otel,go.opentelemetry.io/otel/internal/baggage,Apache-2.0
373+
go.opentelemetry.io/otel,go.opentelemetry.io/otel/internal/global,Apache-2.0
374+
go.opentelemetry.io/otel,go.opentelemetry.io/otel/propagation,Apache-2.0
375+
go.opentelemetry.io/otel/metric,go.opentelemetry.io/otel/metric,Apache-2.0
376+
go.opentelemetry.io/otel/metric,go.opentelemetry.io/otel/metric/embedded,Apache-2.0
377+
go.opentelemetry.io/otel/trace,go.opentelemetry.io/otel/trace,Apache-2.0
352378
go.uber.org/atomic,go.uber.org/atomic,MIT
353379
go.uber.org/multierr,go.uber.org/multierr,MIT
354380
go.uber.org/zap,go.uber.org/zap,MIT
@@ -432,6 +458,8 @@ golang.org/x/tools,golang.org/x/tools/internal/pkgbits,BSD-3-Clause
432458
golang.org/x/tools,golang.org/x/tools/internal/tokeninternal,BSD-3-Clause
433459
golang.org/x/tools,golang.org/x/tools/internal/typeparams,BSD-3-Clause
434460
golang.org/x/tools,golang.org/x/tools/internal/typesinternal,BSD-3-Clause
461+
golang.org/x/xerrors,golang.org/x/xerrors,BSD-3-Clause
462+
golang.org/x/xerrors,golang.org/x/xerrors/internal,BSD-3-Clause
435463
gomodules.xyz/jsonpatch/v2,gomodules.xyz/jsonpatch/v2,Apache-2.0
436464
google.golang.org/appengine,google.golang.org/appengine/internal,Apache-2.0
437465
google.golang.org/appengine,google.golang.org/appengine/internal/base,Apache-2.0
@@ -525,6 +553,9 @@ google.golang.org/protobuf,google.golang.org/protobuf/types/known/emptypb,BSD-3-
525553
google.golang.org/protobuf,google.golang.org/protobuf/types/known/timestamppb,BSD-3-Clause
526554
gopkg.in/DataDog/dd-trace-go.v1,gopkg.in/DataDog/dd-trace-go.v1/ddtrace,Apache-2.0
527555
gopkg.in/DataDog/dd-trace-go.v1,gopkg.in/DataDog/dd-trace-go.v1/ddtrace/ext,Apache-2.0
556+
gopkg.in/DataDog/dd-trace-go.v1,gopkg.in/DataDog/dd-trace-go.v1/ddtrace/internal,Apache-2.0
557+
gopkg.in/DataDog/dd-trace-go.v1,gopkg.in/DataDog/dd-trace-go.v1/ddtrace/opentelemetry,Apache-2.0
558+
gopkg.in/DataDog/dd-trace-go.v1,gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer,Apache-2.0
528559
gopkg.in/DataDog/dd-trace-go.v1,gopkg.in/DataDog/dd-trace-go.v1/internal,Apache-2.0
529560
gopkg.in/DataDog/dd-trace-go.v1,gopkg.in/DataDog/dd-trace-go.v1/internal/appsec,Apache-2.0
530561
gopkg.in/DataDog/dd-trace-go.v1,gopkg.in/DataDog/dd-trace-go.v1/internal/appsec/dyngo,Apache-2.0
@@ -533,7 +564,16 @@ gopkg.in/DataDog/dd-trace-go.v1,gopkg.in/DataDog/dd-trace-go.v1/internal/appsec/
533564
gopkg.in/DataDog/dd-trace-go.v1,gopkg.in/DataDog/dd-trace-go.v1/internal/appsec/dyngo/instrumentation/httpsec,Apache-2.0
534565
gopkg.in/DataDog/dd-trace-go.v1,gopkg.in/DataDog/dd-trace-go.v1/internal/appsec/dyngo/instrumentation/sharedsec,Apache-2.0
535566
gopkg.in/DataDog/dd-trace-go.v1,gopkg.in/DataDog/dd-trace-go.v1/internal/globalconfig,Apache-2.0
567+
gopkg.in/DataDog/dd-trace-go.v1,gopkg.in/DataDog/dd-trace-go.v1/internal/hostname,Apache-2.0
568+
gopkg.in/DataDog/dd-trace-go.v1,gopkg.in/DataDog/dd-trace-go.v1/internal/hostname/azure,Apache-2.0
569+
gopkg.in/DataDog/dd-trace-go.v1,gopkg.in/DataDog/dd-trace-go.v1/internal/hostname/cachedfetch,Apache-2.0
570+
gopkg.in/DataDog/dd-trace-go.v1,gopkg.in/DataDog/dd-trace-go.v1/internal/hostname/ec2,Apache-2.0
571+
gopkg.in/DataDog/dd-trace-go.v1,gopkg.in/DataDog/dd-trace-go.v1/internal/hostname/ecs,Apache-2.0
572+
gopkg.in/DataDog/dd-trace-go.v1,gopkg.in/DataDog/dd-trace-go.v1/internal/hostname/gce,Apache-2.0
573+
gopkg.in/DataDog/dd-trace-go.v1,gopkg.in/DataDog/dd-trace-go.v1/internal/hostname/httputils,Apache-2.0
574+
gopkg.in/DataDog/dd-trace-go.v1,gopkg.in/DataDog/dd-trace-go.v1/internal/hostname/validate,Apache-2.0
536575
gopkg.in/DataDog/dd-trace-go.v1,gopkg.in/DataDog/dd-trace-go.v1/internal/log,Apache-2.0
576+
gopkg.in/DataDog/dd-trace-go.v1,gopkg.in/DataDog/dd-trace-go.v1/internal/namingschema,Apache-2.0
537577
gopkg.in/DataDog/dd-trace-go.v1,gopkg.in/DataDog/dd-trace-go.v1/internal/osinfo,Apache-2.0
538578
gopkg.in/DataDog/dd-trace-go.v1,gopkg.in/DataDog/dd-trace-go.v1/internal/remoteconfig,Apache-2.0
539579
gopkg.in/DataDog/dd-trace-go.v1,gopkg.in/DataDog/dd-trace-go.v1/internal/samplernames,Apache-2.0
@@ -548,7 +588,7 @@ gopkg.in/DataDog/dd-trace-go.v1,gopkg.in/DataDog/dd-trace-go.v1/profiler/interna
548588
gopkg.in/inf.v0,gopkg.in/inf.v0,BSD-3-Clause
549589
gopkg.in/ini.v1,gopkg.in/ini.v1,Apache-2.0
550590
gopkg.in/yaml.v2,gopkg.in/yaml.v2,Apache-2.0
551-
gopkg.in/yaml.v3,gopkg.in/yaml.v3,Apache-2.0
591+
gopkg.in/yaml.v3,gopkg.in/yaml.v3,MIT
552592
inet.af/netaddr,inet.af/netaddr,BSD-3-Clause
553593
k8s.io/api,k8s.io/api/admission/v1,Apache-2.0
554594
k8s.io/api,k8s.io/api/admission/v1beta1,Apache-2.0

api/v1beta1/disruption_spancontext.go

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Unless explicitly stated otherwise all files in this repository are licensed
2+
// under the Apache License Version 2.0.
3+
// This product includes software developed at Datadog (https://www.datadoghq.com/).
4+
// Copyright 2023 Datadog, Inc.
5+
package v1beta1
6+
7+
import (
8+
"context"
9+
"encoding/json"
10+
"fmt"
11+
12+
"go.opentelemetry.io/otel"
13+
"go.opentelemetry.io/otel/propagation"
14+
)
15+
16+
const (
17+
annotationSpanContextKey = "SpanContext"
18+
)
19+
20+
var (
21+
// ErrNoSpanContext is the error returned when the annotation does not contains expected span context key
22+
ErrNoSpanContext = fmt.Errorf("span context not found in disruption annotations")
23+
)
24+
25+
// SpanContext extracts this disruption's span context, injects it in the given context, then returns it
26+
func (r *Disruption) SpanContext(ctx context.Context) (context.Context, error) {
27+
var annotation propagation.MapCarrier
28+
29+
spanContext, ok := r.Annotations[annotationSpanContextKey]
30+
if !ok {
31+
return ctx, ErrNoSpanContext
32+
}
33+
34+
err := json.Unmarshal([]byte(spanContext), &annotation)
35+
if err != nil {
36+
return ctx, fmt.Errorf("unable to unmarshal span context from annotation: %w", err)
37+
}
38+
39+
ctx = otel.GetTextMapPropagator().Extract(ctx, annotation)
40+
41+
return ctx, nil
42+
}
43+
44+
// SetSpanContext store provided spanContext into expected disruption annotation
45+
func (r *Disruption) SetSpanContext(ctx context.Context) error {
46+
var annotation = make(propagation.MapCarrier)
47+
48+
otel.GetTextMapPropagator().Inject(ctx, annotation)
49+
50+
marshaledAnnotation, err := json.Marshal(annotation)
51+
if err != nil {
52+
return fmt.Errorf("unable to marshal span context: %w", err)
53+
}
54+
55+
r.Annotations[annotationSpanContextKey] = string(marshaledAnnotation)
56+
57+
return nil
58+
}

chart/templates/configmap.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ data:
1414
leaderElection: {{ .Values.controller.leaderElection }}
1515
metricsSink: {{ .Values.controller.metricsSink | quote }}
1616
profilerSink: {{ .Values.controller.profilerSink | quote }}
17+
tracerSink: {{ .Values.controller.tracerSink | quote }}
1718
enableSafeguards: {{ .Values.controller.enableSafeguards }}
1819
enableObserver: {{ .Values.controller.enableObserver }}
1920
notifiers:

chart/templates/webhook.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,40 @@ webhooks:
152152
- disruptions/status
153153
{{- end }}
154154
---
155+
apiVersion: admissionregistration.k8s.io/v1
156+
kind: MutatingWebhookConfiguration
157+
metadata:
158+
annotations:
159+
{{- if not .Values.controller.webhook.generateCert }}
160+
cert-manager.io/inject-ca-from: {{ .Values.chaosNamespace }}/chaos-controller-serving-cert
161+
{{- end }}
162+
name: chaos-controller-disruption-span-context
163+
webhooks:
164+
- clientConfig:
165+
{{- if not .Values.controller.webhook.generateCert }}
166+
caBundle: Cg==
167+
{{- else }}
168+
caBundle: {{ b64enc $ca.Cert }}
169+
{{- end }}
170+
service:
171+
name: chaos-controller-webhook-service
172+
namespace: {{ .Values.chaosNamespace }}
173+
path: /mutate-chaos-datadoghq-com-v1beta1-disruption-span-context
174+
failurePolicy: Fail
175+
name: chaos-controller-admission-webhook.{{ .Values.chaosNamespace }}.svc
176+
sideEffects: NoneOnDryRun
177+
admissionReviewVersions: ["v1", "v1beta1"]
178+
rules:
179+
- apiGroups:
180+
- "chaos.datadoghq.com"
181+
apiVersions:
182+
- v1beta1
183+
scope: "Namespaced"
184+
operations:
185+
- CREATE
186+
resources:
187+
- disruptions
188+
---
155189
{{- if not .Values.controller.webhook.generateCert }}
156190
apiVersion: cert-manager.io/v1
157191
kind: Certificate

chart/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ controller:
2626
enableObserver: true # enable observer on targets, notifying of target warning status and events
2727
metricsSink: noop
2828
profilerSink: noop
29+
tracerSink: noop
2930
notifiers:
3031
common:
3132
clusterName: lima

config/config.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ type controllerConfig struct {
3939
UserInfoHook bool `json:"userInfoHook"`
4040
SafeMode safeModeConfig `json:"safeMode"`
4141
ProfilerSink string `json:"profilerSink"`
42+
TracerSink string `json:"tracerSink"`
4243
}
4344

4445
type controllerWebhookConfig struct {
@@ -381,6 +382,12 @@ func New(logger *zap.SugaredLogger, osArgs []string) (config, error) {
381382
return cfg, err
382383
}
383384

385+
mainFS.StringVar(&cfg.Controller.TracerSink, "tracer-sink", "noop", "tracer sink (datadog, or noop)")
386+
387+
if err := viper.BindPFlag("controller.tracerSink", mainFS.Lookup("tracer-sink")); err != nil {
388+
return cfg, err
389+
}
390+
384391
err := preConfigFS.Parse(osArgs)
385392
if err != nil {
386393
return cfg, fmt.Errorf("unable to retrieve configuration parse from provided flag: %w", err)

controllers/disruption_controller.go

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,15 @@ import (
1717
chaosapi "github.com/DataDog/chaos-controller/api"
1818
"github.com/DataDog/chaos-controller/cloudservice"
1919
"github.com/DataDog/chaos-controller/o11y/metrics"
20+
"github.com/DataDog/chaos-controller/o11y/tracer"
2021
"github.com/DataDog/chaos-controller/safemode"
2122
"github.com/DataDog/chaos-controller/targetselector"
2223
chaostypes "github.com/DataDog/chaos-controller/types"
2324
"github.com/DataDog/chaos-controller/watchers"
2425
"github.com/cenkalti/backoff"
26+
"go.opentelemetry.io/otel"
27+
"go.opentelemetry.io/otel/attribute"
28+
"go.opentelemetry.io/otel/trace"
2529
"go.uber.org/zap"
2630
corev1 "k8s.io/api/core/v1"
2731
"k8s.io/apimachinery/pkg/api/errors"
@@ -54,6 +58,7 @@ type DisruptionReconciler struct {
5458
Scheme *runtime.Scheme
5559
Recorder record.EventRecorder
5660
MetricsSink metrics.Sink
61+
TracerSink tracer.Sink
5762
TargetSelector targetselector.TargetSelector
5863
InjectorAnnotations map[string]string
5964
InjectorLabels map[string]string
@@ -89,7 +94,7 @@ type CtxTuple struct {
8994
// +kubebuilder:rbac:groups=core,resources=pods/status,verbs=update;patch
9095
// +kubebuilder:rbac:groups=core,resources=nodes,verbs=list;watch
9196
// +kubebuilder:rbac:groups=core,resources=services,verbs=list;watch
92-
func (r *DisruptionReconciler) Reconcile(_ context.Context, req ctrl.Request) (res ctrl.Result, err error) {
97+
func (r *DisruptionReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res ctrl.Result, err error) {
9398
instance := &chaosv1beta1.Disruption{}
9499
tsStart := time.Now()
95100

@@ -163,6 +168,29 @@ func (r *DisruptionReconciler) Reconcile(_ context.Context, req ctrl.Request) (r
163168
r.log.Errorw("error during the creation of watchers", "error", err)
164169
}
165170

171+
ctx, err = instance.SpanContext(ctx)
172+
if err != nil {
173+
r.log.Errorw("did not find span context", "err", err)
174+
}
175+
176+
userInfo, err := instance.UserInfo()
177+
if err != nil {
178+
r.log.Errorw("error getting user info", "error", err)
179+
180+
userInfo.Username = "did-not-find-user-info@email.com"
181+
}
182+
183+
ctx, reconcileSpan := otel.Tracer("").Start(ctx, "reconcile", trace.WithLinks(trace.LinkFromContext(ctx)),
184+
trace.WithAttributes(
185+
attribute.String("disruption_name", instance.Name),
186+
attribute.String("disruption_namespace", instance.Namespace),
187+
attribute.String("disruption_user", userInfo.Username),
188+
))
189+
defer reconcileSpan.End()
190+
191+
// allows to sync logs with traces
192+
r.log = r.log.With(r.TracerSink.GetLoggableTraceContext(reconcileSpan)...)
193+
166194
// handle any chaos pods being deleted (either by the disruption deletion or by an external event)
167195
if err := r.handleChaosPodsTermination(instance); err != nil {
168196
return ctrl.Result{}, fmt.Errorf("error handling chaos pods termination: %w", err)
@@ -207,6 +235,17 @@ func (r *DisruptionReconciler) Reconcile(_ context.Context, req ctrl.Request) (r
207235
r.handleMetricSinkError(r.MetricsSink.MetricDisruptionCompletedDuration(time.Since(instance.ObjectMeta.CreationTimestamp.Time), []string{"disruptionName:" + instance.Name, "namespace:" + instance.Namespace}))
208236
r.emitKindCountMetrics(instance)
209237

238+
// close the ongoing disruption tracing Span
239+
defer func() {
240+
_, disruptionStopSpan := otel.Tracer("").Start(ctx, "disruption deletion", trace.WithAttributes(
241+
attribute.String("disruption_name", instance.Name),
242+
attribute.String("disruption_namespace", instance.Namespace),
243+
attribute.String("disruption_user", userInfo.Username),
244+
))
245+
246+
disruptionStopSpan.End()
247+
}()
248+
210249
return ctrl.Result{}, nil
211250
}
212251
} else {

0 commit comments

Comments
 (0)