Skip to content

Commit

Permalink
update trace of apiserversource (#6458)
Browse files Browse the repository at this point in the history
  • Loading branch information
liuchangyan authored Aug 4, 2022
1 parent 480c8cb commit 32dea96
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/adapter/apiserver/events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ import (
"strings"
"time"

kncloudevents "knative.dev/eventing/pkg/adapter/v2"

cloudevents "github.com/cloudevents/sdk-go/v2"
ceobs "github.com/cloudevents/sdk-go/v2/observability"
"go.opentelemetry.io/otel/trace"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
kncloudevents "knative.dev/eventing/pkg/adapter/v2"
sources "knative.dev/eventing/pkg/apis/sources"
"knative.dev/eventing/pkg/observability"
)

const (
Expand Down Expand Up @@ -133,6 +135,11 @@ func makeEvent(source, apiServerSourceName, eventType string, obj *unstructured.
Name: apiServerSourceName,
ResourceGroup: resourceGroup,
}

spanName := ceobs.ClientSpanName + " process"
ctx = observability.WithSpanData(ctx, spanName, int(trace.SpanKindProducer),
observability.K8sAttributes(apiServerSourceName, namespace, resourceGroup))

ctx = kncloudevents.ContextWithMetricTag(ctx, metricTag)
ctx = cloudevents.ContextWithRetriesExponentialBackoff(ctx, 50*time.Millisecond, 5)

Expand Down

0 comments on commit 32dea96

Please sign in to comment.