Skip to content

gen: Wrong span error condition in handlers template #1476

@totomojp

Description

@totomojp

What version of ogen are you using?

v1.14.0

Can this issue be reproduced with the latest version?

Yes

What did you do?

Generated server code with OpenTelemetry enabled. The handlers template has incorrect span error condition at line 109:

if code >= 100 && code < 500 {
    span.SetStatus(codes.Error, stage)
}

What did you expect to see?

According to OpenTelemetry conventions, server spans should only be marked as Error for invalid codes (< 100) or server errors (>= 500):

if code < 100 || code >= 500 {
    span.SetStatus(codes.Error, stage)
}

What did you see instead?

The current code incorrectly marks 2xx, 3xx, and 4xx responses as errors, violating OpenTelemetry HTTP semantic conventions and creating false error signals in telemetry data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions