Skip to content

Commit f190d03

Browse files
committed
fix: adapt to event field refactor and log marshal errors
Update span attribute references from l.event to local event variable after upstream refactored shared event field to per-request scope (0faad24). Log json.Marshal errors for span context carrier. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d7ee8c6 commit f190d03

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

pkg/adapter/adapter.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,14 @@ func (l listener) handleEvent(ctx context.Context) http.HandlerFunc {
205205
)
206206

207207
span.SetAttributes(
208-
tracing.VCSEventTypeKey.String(l.event.EventType),
208+
tracing.VCSEventTypeKey.String(event.EventType),
209209
tracing.VCSProviderKey.String(gitProvider.GetConfig().Name),
210210
)
211-
if l.event.URL != "" {
212-
span.SetAttributes(tracing.VCSRepositoryKey.String(l.event.URL))
211+
if event.URL != "" {
212+
span.SetAttributes(tracing.VCSRepositoryKey.String(event.URL))
213213
}
214-
if l.event.SHA != "" {
215-
span.SetAttributes(tracing.VCSRevisionKey.String(l.event.SHA))
214+
if event.SHA != "" {
215+
span.SetAttributes(tracing.VCSRevisionKey.String(event.SHA))
216216
}
217217

218218
s := sinker{

pkg/kubeinteraction/labels.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ func AddLabelsAndAnnotations(ctx context.Context, event *info.Event, pipelineRun
7070

7171
// Add span context for distributed tracing if available
7272
if len(carrier) > 0 {
73-
if jsonBytes, err := json.Marshal(carrier); err == nil {
73+
if jsonBytes, err := json.Marshal(carrier); err != nil {
74+
logging.FromContext(ctx).Errorf("failed to marshal span context carrier: %v", err)
75+
} else {
7476
if existing := pipelineRun.GetAnnotations()[keys.SpanContextAnnotation]; existing != "" {
7577
logging.FromContext(ctx).Warnf("overwriting pre-existing %s annotation on PipelineRun template; honoring initiating event trace context", keys.SpanContextAnnotation)
7678
}

0 commit comments

Comments
 (0)