Skip to content

fix: don't mark successful plugin responses as span errors - #8685

Open
znnnnnnn-wil wants to merge 1 commit into
TykTechnologies:masterfrom
znnnnnnn-wil:fix/otel-status-respond-span-status
Open

fix: don't mark successful plugin responses as span errors#8685
znnnnnnn-wil wants to merge 1 commit into
TykTechnologies:masterfrom
znnnnnnn-wil:fix/otel-status-respond-span-status

Conversation

@znnnnnnn-wil

Copy link
Copy Markdown

Description

Stops TraceMiddleware.ProcessRequest from setting the OpenTelemetry span status to Error when middleware returns ErrResponseSucceed.

ErrResponseSucceed means a Go plugin successfully wrote the response and intentionally terminated the middleware chain. The check uses errors.Is, so wrapped sentinels are handled too. Real failures—including ErrResponseErrorSent for plugin-written 4xx/5xx responses—remain span errors.

Related Issue

Fixes #8684

Motivation and Context

Successful plugin-served 2xx responses currently record the correct HTTP status but an OpenTelemetry status of Error with the description response succeed, inflating tracing error rates.

How This Has Been Tested

Run in golang:1.26-bookworm:

  • go test ./gateway -run '^TestTraceMiddlewareProcessRequestSpanStatus$' -count=1
  • go test -race ./gateway -run '^TestTraceMiddlewareProcessRequestSpanStatus$' -count=1
  • go vet ./gateway

The regression test was first run against the unmodified implementation and failed for direct and wrapped ErrResponseSucceed; it passes after the fix.

Screenshots (if appropriate)

N/A

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactoring or add test (improvements in base code or adds test coverage to functionality)

Checklist

  • I ensured that the documentation is up to date
  • I explained why this PR updates go.mod in detail with reasoning why it's required
  • I would like a code coverage CI quality gate exception and have explained why

@sentinelone-cnapp-eu1

Copy link
Copy Markdown

SentinelOne CNS Hardcoded Secret Detector
✅ Congratulations, your code is safe

SentinelOne CNS is a cloud-agnostic, agentless CSPM & CWPP solution that continuously detects and prevents vulnerabilities that have the highest probability of being exploited in Azure, AWS, Google Cloud, and Kubernetes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OTel: successful plugin-terminated requests (StatusRespond) are recorded as span status Error ("response succeed")

1 participant